Class: Spec::Story::Runner::ScenarioRunner
- Inherits:
-
Object
- Object
- Spec::Story::Runner::ScenarioRunner
- Defined in:
- lib/spec/rails/story_adapter.rb,
lib/spec/story/runner/scenario_runner.rb
Instance Method Summary collapse
- #add_listener(listener) ⇒ Object
-
#initialize ⇒ ScenarioRunner
constructor
A new instance of ScenarioRunner.
- #run(scenario, world) ⇒ Object
Constructor Details
#initialize ⇒ ScenarioRunner
Returns a new instance of ScenarioRunner.
67 68 69 |
# File 'lib/spec/rails/story_adapter.rb', line 67 def initialize @listeners = [ActiveRecordSafetyListener.instance] end |
Instance Method Details
#add_listener(listener) ⇒ Object
34 35 36 |
# File 'lib/spec/story/runner/scenario_runner.rb', line 34 def add_listener(listener) @listeners << listener end |
#run(scenario, world) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/spec/story/runner/scenario_runner.rb', line 9 def run(scenario, world) @listeners.each { |l| l.scenario_started(scenario.story.title, scenario.name) } run_story_ignoring_scenarios(scenario.story, world) world.start_collecting_errors unless scenario.body @listeners.each { |l| l.scenario_pending(scenario.story.title, scenario.name, '') } return true end world.instance_eval(&scenario.body) if world.errors.empty? @listeners.each { |l| l.scenario_succeeded(scenario.story.title, scenario.name) } else if Spec::Example::ExamplePendingError === (e = world.errors.first) @listeners.each { |l| l.scenario_pending(scenario.story.title, scenario.name, e.) } else @listeners.each { |l| l.scenario_failed(scenario.story.title, scenario.name, e) } return false end end true end |