System notice: In light of the Debian OpenSSL security issue we've regenerated the server keys. See this thread for instructions and the new key fingerprints.

Commit 438bad354b85e3f26fe194ae19e3b0aef470b627

fixed bug where stories (in rails only) were loading two copies of options (and therefore losing the command line options, leaving only defaults).

Commit diff

rspec/lib/spec/runner/formatter/profile_formatter.rb

 
4141 end
4242 @output.flush
4343 end
44
45 def method_missing(sym, *args)
46 # ignore
47 end
4448 end
4549 end
4650 end
toggle raw diff

rspec/lib/spec/runner/formatter/progress_bar_formatter.rb

 
2424 @output.puts
2525 @output.flush
2626 end
27
28 def method_missing(sym, *args)
29 # ignore
30 end
2731 end
2832 end
2933 end
toggle raw diff

rspec/lib/spec/story/runner.rb

 
1010 module Runner
1111 class << self
1212 def run_options # :nodoc:
13 @run_options ||= ::Spec::Runner::OptionParser.parse(ARGV, $stderr, $stdout)
13 rspec_options
14 # @run_options ||= ::Spec::Runner::OptionParser.parse(ARGV, $stderr, $stdout)
1415 end
1516
1617 def story_runner # :nodoc:
1718 unless @story_runner
18 @story_runner = StoryRunner.new(scenario_runner, world_creator)
19 @story_runner = create_story_runner
1920 run_options.story_formatters.each do |formatter|
2021 register_listener(formatter)
2122 end
22 Runner.register_exit_hook
23 self.register_exit_hook
2324 end
2425 @story_runner
2526 end
3333 @world_creator ||= World
3434 end
3535
36 def create_story_runner
37 StoryRunner.new(scenario_runner, world_creator)
38 end
39
3640 # Use this to register a customer output formatter.
3741 def register_listener(listener)
3842 story_runner.add_listener(listener) # run_started, story_started, story_ended, #run_ended
4545 end
4646
4747 def register_exit_hook # :nodoc:
48 puts caller(0)[1]
4849 at_exit do
4950 exit Runner.story_runner.run_stories unless $!
5051 end
51
5252 end
5353
5454 def dry_run
toggle raw diff

rspec/lib/spec/story/runner/plain_text_story_runner.rb

 
2626 @story_file = path
2727 end
2828
29 def run
29 def run(story_runner=Spec::Story::Runner.story_runner)
3030 raise "You must set a path to the file with the story. See the RDoc." if @story_file.nil?
31 mediator = Spec::Story::Runner::StoryMediator.new(steps, Spec::Story::Runner.story_runner, @options)
31 mediator = Spec::Story::Runner::StoryMediator.new(steps, story_runner, @options)
3232 parser = Spec::Story::Runner::StoryParser.new(mediator)
3333
3434 story_text = File.read(@story_file)
toggle raw diff

rspec/lib/spec/version.rb

 
66 TINY = 3
77 RELEASE_CANDIDATE = nil
88
9 BUILD_TIME_UTC = 20080325021625
9 BUILD_TIME_UTC = 20080328014754
1010
1111 STRING = [MAJOR, MINOR, TINY].join('.')
1212 TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
toggle raw diff

rspec/spec/spec/story/runner/plain_text_story_runner_spec.rb

 
2222
2323 it "should parse a story file" do
2424 runner = PlainTextStoryRunner.new("path")
25
2625 during {
27 runner.run
26 runner.run(mock('runner'))
2827 }.expect {
2928 @parser.should_receive(:parse).with(["this", "and that"])
3029 }
3130 end
3231
3332 it "should build up a mediator with its own steps and the singleton story_runner" do
33 @story_runner = mock('story runner', :null_object => true)
34
3435 runner = PlainTextStoryRunner.new("path")
35 Spec::Story::Runner.should_receive(:story_runner).and_return(story_runner = mock("story runner"))
36 Spec::Story::Runner::StoryMediator.should_receive(:new).with(runner.steps, story_runner, {}).
37 and_return(mediator = stub("mediator", :run_stories => nil))
38 runner.run
36
37 Spec::Story::Runner::StoryMediator.should_receive(:new).with(
38 runner.steps, @story_runner, {}
39 ).and_return(mediator = stub("mediator", :run_stories => nil))
40 runner.run(@story_runner)
3941 end
4042
4143 it "should build up a parser with the mediator" do
4244 runner = PlainTextStoryRunner.new("path")
43 Spec::Story::Runner.should_receive(:story_runner).and_return(story_runner = mock("story runner"))
4445 Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator = stub("mediator", :run_stories => nil))
4546 Spec::Story::Runner::StoryParser.should_receive(:new).with(mediator).and_return(@parser)
46 runner.run
47 runner.run(stub("story_runner"))
4748 end
4849
4950 it "should tell the mediator to run the stories" do
5252 mediator = mock("mediator")
5353 Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator)
5454 mediator.should_receive(:run_stories)
55 runner.run
55 runner.run(mock('runner'))
5656 end
5757
5858 it "should accept a block instead of a path" do
6060 runner.load("path/to/story")
6161 end
6262 File.should_receive(:read).with("path/to/story").and_return("this\nand that")
63 runner.run
63 runner.run(mock('runner'))
6464 end
6565
6666 it "should tell you if you try to run with no path set" do
6767 runner = PlainTextStoryRunner.new
6868 lambda {
69 runner.run
69 runner.run(mock('runner'))
7070 }.should raise_error(RuntimeError, "You must set a path to the file with the story. See the RDoc.")
7171 end
7272
7575 Spec::Story::Runner::StoryMediator.should_receive(:new).
7676 with(anything, anything, :foo => :bar).
7777 and_return(mediator = stub("mediator", :run_stories => nil))
78 runner.run
78 runner.run(mock('runner'))
7979 end
8080
8181 it "should provide access to its options" do
8484 Spec::Story::Runner::StoryMediator.should_receive(:new).
8585 with(anything, anything, :foo => :bar).
8686 and_return(mediator = stub("mediator", :run_stories => nil))
87 runner.run
87 runner.run mock('runner')
8888 end
8989
9090 end
toggle raw diff

rspec/spec/spec/story/runner/story_mediator_spec.rb

 
4747 @runner.scenarios.first.name.should == "scenario name"
4848 @runner.scenarios.first.story.should == @runner.stories.first
4949 end
50
50
5151 it "should create a given scenario step if one matches" do
5252 pending("need to untangle the dark mysteries of the story runner - something needs to get stubbed here") do
5353 story = @mediator.create_story "title", "narrative"
120120 it "should pass options to the stories it creates" do
121121 @mediator = StoryMediator.new @step_group, @runner, :foo => :bar
122122 @mediator.create_story "story title", "story narrative"
123
123
124124 run_stories
125125
126126 @runner.stories.first[:foo].should == :bar
toggle raw diff

rspec/spec/spec/story/runner_spec.rb

 
11require File.dirname(__FILE__) + '/story_helper'
2require 'spec/runner/formatter/story/plain_text_formatter'
3require 'spec/runner/formatter/story/html_formatter'
24
35module Spec
46 module Story
57 describe Runner, "module" do
6 def dev_null
7 io = StringIO.new
8 def io.write(str)
9 str.to_s.size
10 end
11 return io
12 end
13
14 before :each do
15 Kernel.stub!(:at_exit)
16 @stdout, $stdout = $stdout, dev_null
17 @argv = Array.new(ARGV)
18 @runner_module = Runner.dup
8 before(:each) do
199 @world_creator = World.dup
20 @runner_module.module_eval { @run_options = @story_runner = @scenario_runner = @world_creator = nil }
10 @runner_module = Runner.dup
11 @runner_module.instance_eval {@story_runner = nil}
12 @runner_module.stub!(:register_exit_hook)
2113 end
2214
23 after :each do
24 $stdout = @stdout
25 ARGV.replace @argv
26 @runner_module.module_eval { @run_options = @story_runner = @scenario_runner = @world_creator = nil }
15 def create_options(args=[])
16 Spec::Runner::OptionParser.parse(args, StringIO.new, StringIO.new)
2717 end
2818
2919 it 'should wire up a singleton StoryRunner' do
2222
2323 it 'should set its options based on ARGV' do
2424 # given
25 ARGV << '--dry-run'
26
25 @runner_module.should_receive(:run_options).and_return(
26 create_options(['--dry-run'])
27 )
28
2729 # when
2830 options = @runner_module.run_options
2931
3032 # then
3133 options.dry_run.should be_true
3234 end
33
34 it 'should add a reporter to the runner classes' do
35 # given
36 story_runner = mock('story runner', :null_object => true)
37 scenario_runner = mock('scenario runner', :null_object => true)
38 world_creator = mock('world', :null_object => true)
39
40 @runner_module::class_eval { @world_creator = world_creator }
41 @runner_module::StoryRunner.stub!(:new).and_return(story_runner)
42 @runner_module::ScenarioRunner.stub!(:new).and_return(scenario_runner)
43
44 # expect
45 world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
46 story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
47 scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
48
49 # when
50 @runner_module.story_runner
51 end
5235
53 it 'should add a documenter to the runner classes if one is specified' do
54 # given
55 ARGV << "--format" << "html"
56 story_runner = mock('story runner', :null_object => true)
57 scenario_runner = mock('scenario runner', :null_object => true)
58 world_creator = mock('world', :null_object => true)
36 describe "initialization" do
5937
60 @runner_module::class_eval { @world_creator = world_creator }
61 @runner_module::StoryRunner.stub!(:new).and_return(story_runner)
62 @runner_module::ScenarioRunner.stub!(:new).and_return(scenario_runner)
38 before(:each) do
39 # given
40 @story_runner = mock('story runner', :null_object => true)
41 @scenario_runner = mock('scenario runner', :null_object => true)
42 @world_creator = mock('world', :null_object => true)
6343
64 # expect
65 world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
66 story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
67 scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
44 @runner_module.stub!(:world_creator).and_return(@world_creator)
45 @runner_module.stub!(:create_story_runner).and_return(@story_runner)
46 @runner_module.stub!(:scenario_runner).and_return(@scenario_runner)
47 end
48
49 it 'should add a reporter to the runner classes' do
50 @runner_module.should_receive(:run_options).and_return(
51 create_options
52 )
6853
69 # when
70 @runner_module.story_runner
71 end
54 # expect
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))
58
59 # when
60 @runner_module.story_runner
61 end
7262
73 it 'should add any registered listener to the runner classes' do
74 # given
75 ARGV << "--format" << "html"
76 story_runner = mock('story runner', :null_object => true)
77 scenario_runner = mock('scenario runner', :null_object => true)
78 world_creator = mock('world', :null_object => true)
63 it 'should add a documenter to the runner classes if one is specified' do
7964
80 @runner_module::class_eval { @world_creator = world_creator }
81 @runner_module::StoryRunner.stub!(:new).and_return(story_runner)
82 @runner_module::ScenarioRunner.stub!(:new).and_return(scenario_runner)
65 @runner_module.should_receive(:run_options).and_return(
66 create_options(["--format","html"])
67 )
68
69 # expect
70 @world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
71 @story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
72 @scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
8373
84 listener = Object.new
74 # when
75 @runner_module.story_runner
76 end
77
78 it 'should add any registered listener to the runner classes' do
79 # given
80 listener = Object.new
8581
86 # expect
87 world_creator.should_receive(:add_listener).with(listener)
88 story_runner.should_receive(:add_listener).with(listener)
89 scenario_runner.should_receive(:add_listener).with(listener)
82 # expect
83 @world_creator.should_receive(:add_listener).with(listener)
84 @story_runner.should_receive(:add_listener).with(listener)
85 @scenario_runner.should_receive(:add_listener).with(listener)
9086
91 # when
92 @runner_module.register_listener listener
87 # when
88 @runner_module.register_listener listener
89 end
90 end
9391 end
94 end
9592 end
9693end
toggle raw diff

rspec/stories/example_groups/stories.rb

 
11require File.join(File.dirname(__FILE__), *%w[.. helper])
22
33with_steps_for :running_rspec do
4 Dir["#{File.dirname(__FILE__)}/*"].each do |file|
5 run file if File.file?(file) && !(file =~ /\.rb$/)
6 end
4 run File.dirname(__FILE__) + "/nested_groups"
5 # Dir["#{File.dirname(__FILE__)}/*"].each do |file|
6 # run file if File.file?(file) && !(file =~ /\.rb$/)
7 # end
78end
toggle raw diff

rspec_on_rails/lib/spec/rails/version.rb

 
11module Spec
22 module Rails
33 module VERSION #:nodoc:
4 BUILD_TIME_UTC = 20080325021625
4 BUILD_TIME_UTC = 20080328014754
55 end
66 end
77end
toggle raw diff