changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/lib/spec/story/runner.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1require 'spec/story/runner/scenario_collector.rb'
2require 'spec/story/runner/scenario_runner.rb'
3require 'spec/story/runner/story_runner.rb'
4require 'spec/story/runner/story_parser.rb'
5require 'spec/story/runner/story_mediator.rb'
6require 'spec/story/runner/plain_text_story_runner.rb'
7
8module Spec
9 module Story
10 module Runner
11 class << self
12 def run_options # :nodoc:
13 @run_options ||= ::Spec::Runner::OptionParser.parse(ARGV, $stderr, $stdout)
14 end
15
16 def story_runner # :nodoc:
17 unless @story_runner
18 @story_runner = StoryRunner.new(scenario_runner, world_creator)
19 run_options.story_formatters.each do |formatter|
20 register_listener(formatter)
21 end
22 Runner.register_exit_hook
23 end
24 @story_runner
25 end
26
27 def scenario_runner # :nodoc:
28 @scenario_runner ||= ScenarioRunner.new
29 end
30
31 def world_creator # :nodoc:
32 @world_creator ||= World
33 end
34
35 # Use this to register a customer output formatter.
36 def register_listener(listener)
37 story_runner.add_listener(listener) # run_started, story_started, story_ended, #run_ended
38 world_creator.add_listener(listener) # found_scenario, step_succeeded, step_failed, step_failed
39 scenario_runner.add_listener(listener) # scenario_started, scenario_succeeded, scenario_pending, scenario_failed
40 end
41
42 def register_exit_hook # :nodoc:
43 at_exit do
44 Runner.story_runner.run_stories unless $!
45 end
46 # TODO exit with non-zero status if run fails
47 end
48
49 def dry_run
50 run_options.dry_run
51 end
52
53 end
54 end
55 end
56end