Class: Spec::Story::Runner::StoryRunner
- Defined in:
- lib/gems/rspec-1.1.11/lib/spec/story/runner/story_runner.rb
Class Attribute Summary collapse
-
.current_story_runner ⇒ Object
Returns the value of attribute current_story_runner.
Instance Attribute Summary collapse
-
#current_story ⇒ Object
Returns the value of attribute current_story.
-
#scenarios ⇒ Object
Returns the value of attribute scenarios.
-
#stories ⇒ Object
Returns the value of attribute stories.
Class Method Summary collapse
Instance Method Summary collapse
- #add_listener(listener) ⇒ Object
-
#initialize(scenario_runner, world_creator = World) ⇒ StoryRunner
constructor
A new instance of StoryRunner.
- #run_stories ⇒ Object
- #scenario_from_current_story(scenario_name) ⇒ Object
- #Story(title, narrative, params = {}, &body) ⇒ Object
Constructor Details
#initialize(scenario_runner, world_creator = World) ⇒ StoryRunner
Returns a new instance of StoryRunner.
15 16 17 18 19 20 21 22 23 |
# File 'lib/gems/rspec-1.1.11/lib/spec/story/runner/story_runner.rb', line 15 def initialize(scenario_runner, world_creator = World) StoryRunner.current_story_runner = self @scenario_runner = scenario_runner @world_creator = world_creator @stories = [] @scenarios_by_story = {} @scenarios = [] @listeners = [] end |
Class Attribute Details
.current_story_runner ⇒ Object
Returns the value of attribute current_story_runner.
6 7 8 |
# File 'lib/gems/rspec-1.1.11/lib/spec/story/runner/story_runner.rb', line 6 def current_story_runner @current_story_runner end |
Instance Attribute Details
#current_story ⇒ Object
Returns the value of attribute current_story.
13 14 15 |
# File 'lib/gems/rspec-1.1.11/lib/spec/story/runner/story_runner.rb', line 13 def current_story @current_story end |
#scenarios ⇒ Object
Returns the value of attribute scenarios.
13 14 15 |
# File 'lib/gems/rspec-1.1.11/lib/spec/story/runner/story_runner.rb', line 13 def scenarios @scenarios end |
#stories ⇒ Object
Returns the value of attribute stories.
13 14 15 |
# File 'lib/gems/rspec-1.1.11/lib/spec/story/runner/story_runner.rb', line 13 def stories @stories end |
Class Method Details
.scenario_from_current_story(scenario_name) ⇒ Object
8 9 10 |
# File 'lib/gems/rspec-1.1.11/lib/spec/story/runner/story_runner.rb', line 8 def scenario_from_current_story(scenario_name) current_story_runner.scenario_from_current_story(scenario_name) end |
Instance Method Details
#add_listener(listener) ⇒ Object
60 61 62 |
# File 'lib/gems/rspec-1.1.11/lib/spec/story/runner/story_runner.rb', line 60 def add_listener(listener) @listeners << listener end |
#run_stories ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/gems/rspec-1.1.11/lib/spec/story/runner/story_runner.rb', line 36 def run_stories return if @stories.empty? @listeners.each { |l| l.run_started(scenarios.size) } success = true @stories.each do |story| story.assign_steps_to(World) @current_story = story @listeners.each { |l| l.story_started(story.title, story.narrative) } scenarios = @scenarios_by_story[story.title] scenarios.each do |scenario| type = story[:type] || Object args = story[:args] || [] world = @world_creator.create(type, *args) success = success & @scenario_runner.run(scenario, world) end @listeners.each { |l| l.story_ended(story.title, story.narrative) } World.step_mother.clear end unique_steps = (World.step_names.collect {|n| Regexp === n ? n.source : n.to_s}).uniq.sort @listeners.each { |l| l.collected_steps(unique_steps) } @listeners.each { |l| l.run_ended } return success end |
#scenario_from_current_story(scenario_name) ⇒ Object
64 65 66 |
# File 'lib/gems/rspec-1.1.11/lib/spec/story/runner/story_runner.rb', line 64 def scenario_from_current_story(scenario_name) @scenarios_by_story[@current_story.title].find {|s| s.name == scenario_name } end |
#Story(title, narrative, params = {}, &body) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gems/rspec-1.1.11/lib/spec/story/runner/story_runner.rb', line 25 def Story(title, narrative, params = {}, &body) story = Story.new(title, narrative, params, &body) @stories << story # collect scenarios collector = ScenarioCollector.new(story) story.run_in(collector) @scenarios += collector.scenarios @scenarios_by_story[story.title] = collector.scenarios end |