1
require File.dirname(__FILE__) + '/story_helper'
5
describe Runner, "module" do
15
Kernel.stub!(:at_exit)
16
@stdout, $stdout = $stdout, dev_null
17
@argv = Array.new(ARGV)
18
@runner_module = Runner.dup
19
@world_creator = World.dup
20
@runner_module.module_eval { @run_options = @story_runner = @scenario_runner = @world_creator = nil }
26
@runner_module.module_eval { @run_options = @story_runner = @scenario_runner = @world_creator = nil }
29
it 'should wire up a singleton StoryRunner' do
30
@runner_module.story_runner.should_not be_nil
33
it 'should set its options based on ARGV' do
38
options = @runner_module.run_options
41
options.dry_run.should be_true
44
it 'should add a reporter to the runner classes' do
46
story_runner = mock('story runner', :null_object => true)
47
scenario_runner = mock('scenario runner', :null_object => true)
48
world_creator = mock('world', :null_object => true)
50
@runner_module::class_eval { @world_creator = world_creator }
51
@runner_module::StoryRunner.stub!(:new).and_return(story_runner)
52
@runner_module::ScenarioRunner.stub!(:new).and_return(scenario_runner)
55
world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
56
story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
57
scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
60
@runner_module.story_runner
63
it 'should add a documenter to the runner classes if one is specified' do
65
ARGV << "--format" << "html"
66
story_runner = mock('story runner', :null_object => true)
67
scenario_runner = mock('scenario runner', :null_object => true)
68
world_creator = mock('world', :null_object => true)
70
@runner_module::class_eval { @world_creator = world_creator }
71
@runner_module::StoryRunner.stub!(:new).and_return(story_runner)
72
@runner_module::ScenarioRunner.stub!(:new).and_return(scenario_runner)
75
world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
76
story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
77
scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
80
@runner_module.story_runner
83
it 'should add any registered listener to the runner classes' do
85
ARGV << "--format" << "html"
86
story_runner = mock('story runner', :null_object => true)
87
scenario_runner = mock('scenario runner', :null_object => true)
88
world_creator = mock('world', :null_object => true)
90
@runner_module::class_eval { @world_creator = world_creator }
91
@runner_module::StoryRunner.stub!(:new).and_return(story_runner)
92
@runner_module::ScenarioRunner.stub!(:new).and_return(scenario_runner)
97
world_creator.should_receive(:add_listener).with(listener)
98
story_runner.should_receive(:add_listener).with(listener)
99
scenario_runner.should_receive(:add_listener).with(listener)
102
@runner_module.register_listener listener