0
require File.dirname(__FILE__) + '/story_helper'
0
+require 'spec/runner/formatter/story/plain_text_formatter'
0
+require 'spec/runner/formatter/story/html_formatter'
0
describe Runner, "module" do
0
- Kernel.stub!(:at_exit)
0
- @stdout, $stdout = $stdout, dev_null
0
- @argv = Array.new(ARGV)
0
- @runner_module = Runner.dup
0
@world_creator = World.dup
0
- @runner_module.module_eval { @run_options = @story_runner = @scenario_runner = @world_creator = nil }
0
+ @runner_module = Runner.dup
0
+ @runner_module.instance_eval {@story_runner = nil}
0
+ @runner_module.stub!(:register_exit_hook)
0
- @runner_module.module_eval { @run_options = @story_runner = @scenario_runner = @world_creator = nil }
0
+ def create_options(args=[])
0
+ Spec::Runner::OptionParser.parse(args, StringIO.new, StringIO.new)
0
it 'should wire up a singleton StoryRunner' do
0
@@ -32,75 +22,72 @@ module Spec
0
it 'should set its options based on ARGV' do
0
+ @runner_module.should_receive(:run_options).and_return(
0
+ create_options(['--dry-run'])
0
options = @runner_module.run_options
0
options.dry_run.should be_true
0
- it 'should add a reporter to the runner classes' do
0
- story_runner = mock('story runner', :null_object => true)
0
- scenario_runner = mock('scenario runner', :null_object => true)
0
- world_creator = mock('world', :null_object => true)
0
- @runner_module::class_eval { @world_creator = world_creator }
0
- @runner_module::StoryRunner.stub!(:new).and_return(story_runner)
0
- @runner_module::ScenarioRunner.stub!(:new).and_return(scenario_runner)
0
- world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
0
- story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
0
- scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
0
- @runner_module.story_runner
0
- it 'should add a documenter to the runner classes if one is specified' do
0
- ARGV << "--format" << "html"
0
- story_runner = mock('story runner', :null_object => true)
0
- scenario_runner = mock('scenario runner', :null_object => true)
0
- world_creator = mock('world', :null_object => true)
0
+ describe "initialization" do
0
- @runner_module::class_eval { @world_creator = world_creator }
0
- @runner_module::StoryRunner.stub!(:new).and_return(story_runner)
0
- @runner_module::ScenarioRunner.stub!(:new).and_return(scenario_runner)
0
+ @story_runner = mock('story runner', :null_object => true)
0
+ @scenario_runner = mock('scenario runner', :null_object => true)
0
+ @world_creator = mock('world', :null_object => true)
0
- world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
0
- story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
0
- scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
0
+ @runner_module.stub!(:world_creator).and_return(@world_creator)
0
+ @runner_module.stub!(:create_story_runner).and_return(@story_runner)
0
+ @runner_module.stub!(:scenario_runner).and_return(@scenario_runner)
0
+ it 'should add a reporter to the runner classes' do
0
+ @runner_module.should_receive(:run_options).and_return(
0
- @runner_module.story_runner
0
+ @world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
0
+ @story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
0
+ @scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
0
+ @runner_module.story_runner
0
- it 'should add any registered listener to the runner classes' do
0
- ARGV << "--format" << "html"
0
- story_runner = mock('story runner', :null_object => true)
0
- scenario_runner = mock('scenario runner', :null_object => true)
0
- world_creator = mock('world', :null_object => true)
0
+ it 'should add a documenter to the runner classes if one is specified' do
0
- @runner_module::class_eval { @world_creator = world_creator }
0
- @runner_module::StoryRunner.stub!(:new).and_return(story_runner)
0
- @runner_module::ScenarioRunner.stub!(:new).and_return(scenario_runner)
0
+ @runner_module.should_receive(:run_options).and_return(
0
+ create_options(["--format","html"])
0
+ @world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
0
+ @story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
0
+ @scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
0
+ @runner_module.story_runner
0
+ it 'should add any registered listener to the runner classes' do
0
- world_creator.should_receive(:add_listener).with(listener)
0
- story_runner.should_receive(:add_listener).with(listener)
0
- scenario_runner.should_receive(:add_listener).with(listener)
0
+ @world_creator.should_receive(:add_listener).with(listener)
0
+ @story_runner.should_receive(:add_listener).with(listener)
0
+ @scenario_runner.should_receive(:add_listener).with(listener)
0
- @runner_module.register_listener listener
0
+ @runner_module.register_listener listener
Comments
No one has commented yet.