Class: RBehave::Runner::StoryRunner
- Inherits:
-
Object
- Object
- RBehave::Runner::StoryRunner
- Defined in:
- lib/rbehave/runner/story_runner.rb
Instance Attribute Summary collapse
-
#scenarios ⇒ Object
Returns the value of attribute scenarios.
-
#stories ⇒ Object
Returns the value of attribute stories.
Instance Method Summary collapse
- #add_listener(listener) ⇒ Object
-
#initialize(scenario_runner, world_creator = World) ⇒ StoryRunner
constructor
A new instance of StoryRunner.
- #run_stories ⇒ Object
- #Story(title, narrative, &body) ⇒ Object
Constructor Details
#initialize(scenario_runner, world_creator = World) ⇒ StoryRunner
Returns a new instance of StoryRunner.
6 7 8 9 10 11 12 13 |
# File 'lib/rbehave/runner/story_runner.rb', line 6 def initialize(scenario_runner, world_creator = World) @scenario_runner = scenario_runner @world_creator = world_creator @stories = [] @scenarios_by_story = {} @scenarios = [] @listeners = [] end |
Instance Attribute Details
#scenarios ⇒ Object
Returns the value of attribute scenarios.
4 5 6 |
# File 'lib/rbehave/runner/story_runner.rb', line 4 def scenarios @scenarios end |
#stories ⇒ Object
Returns the value of attribute stories.
4 5 6 |
# File 'lib/rbehave/runner/story_runner.rb', line 4 def stories @stories end |
Instance Method Details
#add_listener(listener) ⇒ Object
39 40 41 |
# File 'lib/rbehave/runner/story_runner.rb', line 39 def add_listener(listener) @listeners << listener end |
#run_stories ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rbehave/runner/story_runner.rb', line 26 def run_stories @listeners.each { |l| l.run_started(scenarios.size) } @stories.each do |story| @listeners.each { |l| l.story_started(story.title, story.narrative) } scenarios = @scenarios_by_story[story.title] scenarios.each do |scenario| @scenario_runner.run(scenario, @world_creator.create) end @listeners.each { |l| l.story_ended(story.title, story.narrative) } end @listeners.each { |l| l.run_ended } end |
#Story(title, narrative, &body) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rbehave/runner/story_runner.rb', line 15 def Story(title, narrative, &body) story = Story.new(title, narrative, &body) @stories << story # collect scenarios collector = ScenarioCollector.new(story) story.run_in(collector) @scenarios += collector.scenarios @scenarios_by_story[story.title] = collector.scenarios end |