Module | Spec::Story::World |
In: |
vendor/plugins/rspec/lib/spec/story/world.rb
|
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 30 30: def add_listener(listener) 31: listeners() << listener 32: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 22 22: def create(cls = Object, *args) 23: cls.new(*args).extend(World) 24: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 90 90: def dry_run 91: ::Spec::Story::Runner.dry_run 92: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 86 86: def errors 87: @errors ||= [] 88: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 26 26: def listeners 27: @listeners ||= [] 28: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 46 46: def run_given_scenario_with_suspended_listeners(world, type, name, scenario) 47: current_listeners = Array.new(listeners) 48: begin 49: listeners.each { |l| l.found_scenario(type, name) } 50: @listeners.clear 51: scenario.perform(world, name) unless dry_run 52: ensure 53: @listeners.replace(current_listeners) 54: end 55: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 34 34: def step_mother 35: @step_mother ||= StepMother.new 36: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 42 42: def step_names 43: @step_names ||= [] 44: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 57 57: def store_and_call(world, type, name, *args, &block) 58: if block_given? 59: step_mother.store(type, Step.new(name, &block)) 60: end 61: step = step_mother.find(type, name) 62: 63: step_name = step.name 64: step_names << step_name 65: 66: # It's important to have access to the parsed args here, so 67: # we can give them to the listeners. The HTML reporter needs 68: # the args so it can style them. See the generated output in 69: # story_server/prototype/rspec_stories.html (generated by rake stories) 70: args = step.parse_args(name) if args.empty? 71: begin 72: listeners.each { |l| l.step_upcoming(type, step_name, *args) } 73: step.perform(world, *args) unless dry_run 74: listeners.each { |l| l.step_succeeded(type, step_name, *args) } 75: rescue Exception => e 76: case e 77: when Spec::Example::ExamplePendingError 78: @listeners.each { |l| l.step_pending(type, step_name, *args) } 79: else 80: @listeners.each { |l| l.step_failed(type, step_name, *args) } 81: end 82: errors << e 83: end 84: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 38 38: def use(steps) 39: step_mother.use(steps) 40: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 123 123: def And(name, *args, &block) 124: World.store_and_call self, @__previous_step, name, *args, &block 125: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 108 108: def Given(name, *args, &block) 109: World.store_and_call self, :given, name, *args, &block 110: @__previous_step = :given 111: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 103 103: def GivenScenario(name) 104: World.run_given_scenario_with_suspended_listeners(self, :'given scenario', name, GivenScenario.new(name)) 105: @__previous_step = :given 106: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 118 118: def Then(name, *args, &block) 119: World.store_and_call self, :then, name, *args, &block 120: @__previous_step = :then 121: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 113 113: def When(name, *args, &block) 114: World.store_and_call self, :when, name, *args, &block 115: @__previous_step = :when 116: end
# File vendor/plugins/rspec/lib/spec/story/world.rb, line 99 99: def errors 100: World.errors 101: end