| 1 |
require 'spec/story/runner/scenario_collector.rb' |
| 2 |
require 'spec/story/runner/scenario_runner.rb' |
| 3 |
require 'spec/story/runner/story_runner.rb' |
| 4 |
require 'spec/story/runner/story_parser.rb' |
| 5 |
require 'spec/story/runner/story_mediator.rb' |
| 6 |
require 'spec/story/runner/plain_text_story_runner.rb' |
| 7 |
|
| 8 |
module Spec |
| 9 |
module Story |
| 10 |
module Runner |
| 11 |
class << self |
| 12 |
def run_options |
| 13 |
rspec_options |
| 14 |
|
| 15 |
end |
| 16 |
|
| 17 |
def story_runner |
| 18 |
unless @story_runner |
| 19 |
@story_runner = create_story_runner |
| 20 |
run_options.story_formatters.each do |formatter| |
| 21 |
register_listener(formatter) |
| 22 |
end |
| 23 |
self.register_exit_hook |
| 24 |
end |
| 25 |
@story_runner |
| 26 |
end |
| 27 |
|
| 28 |
def scenario_runner |
| 29 |
@scenario_runner ||= ScenarioRunner.new |
| 30 |
end |
| 31 |
|
| 32 |
def world_creator |
| 33 |
@world_creator ||= World |
| 34 |
end |
| 35 |
|
| 36 |
def create_story_runner |
| 37 |
StoryRunner.new(scenario_runner, world_creator) |
| 38 |
end |
| 39 |
|
| 40 |
|
| 41 |
def register_listener(listener) |
| 42 |
story_runner.add_listener(listener) |
| 43 |
world_creator.add_listener(listener) |
| 44 |
scenario_runner.add_listener(listener) |
| 45 |
end |
| 46 |
|
| 47 |
def register_exit_hook |
| 48 |
at_exit do |
| 49 |
exit Runner.story_runner.run_stories unless $! |
| 50 |
end |
| 51 |
end |
| 52 |
|
| 53 |
def dry_run |
| 54 |
run_options.dry_run |
| 55 |
end |
| 56 |
|
| 57 |
end |
| 58 |
end |
| 59 |
end |
| 60 |
end |