GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: Textmate bundle for RSpec.
Clone URL: git://github.com/dchelimsky/rspec-tmbundle.git
fixed bug where stories (in rails only) were loading two copies of options 
(and therefore losing the command line options, leaving only defaults).
dchelimsky (author)
Thu Mar 27 18:54:52 -0700 2008
commit  438bad354b85e3f26fe194ae19e3b0aef470b627
tree    89d912888169b4a62e6dfcbbcd4c9a0dbb1e9226
parent  57f9ef29162c10bc1438d1d41f063471fdf4c11d
...
41
42
43
 
 
 
 
44
45
46
...
41
42
43
44
45
46
47
48
49
50
0
@@ -41,6 +41,10 @@ module Spec
0
           end
0
           @output.flush
0
         end
0
+
0
+ def method_missing(sym, *args)
0
+ # ignore
0
+ end
0
       end
0
     end
0
   end
...
24
25
26
 
 
 
 
27
28
29
...
24
25
26
27
28
29
30
31
32
33
0
@@ -24,6 +24,10 @@ module Spec
0
           @output.puts
0
           @output.flush
0
         end
0
+
0
+ def method_missing(sym, *args)
0
+ # ignore
0
+ end
0
       end
0
     end
0
   end
...
10
11
12
13
 
 
14
15
16
17
18
 
19
20
21
22
 
23
24
25
...
32
33
34
 
 
 
 
35
36
37
...
40
41
42
 
43
44
45
46
47
48
49
...
10
11
12
 
13
14
15
16
17
18
 
19
20
21
22
 
23
24
25
26
...
33
34
35
36
37
38
39
40
41
42
...
45
46
47
48
49
50
51
 
52
53
54
0
@@ -10,16 +10,17 @@ module Spec
0
     module Runner
0
       class << self
0
         def run_options # :nodoc:
0
- @run_options ||= ::Spec::Runner::OptionParser.parse(ARGV, $stderr, $stdout)
0
+ rspec_options
0
+ # @run_options ||= ::Spec::Runner::OptionParser.parse(ARGV, $stderr, $stdout)
0
         end
0
         
0
         def story_runner # :nodoc:
0
           unless @story_runner
0
- @story_runner = StoryRunner.new(scenario_runner, world_creator)
0
+ @story_runner = create_story_runner
0
             run_options.story_formatters.each do |formatter|
0
               register_listener(formatter)
0
             end
0
- Runner.register_exit_hook
0
+ self.register_exit_hook
0
           end
0
           @story_runner
0
         end
0
@@ -32,6 +33,10 @@ module Spec
0
           @world_creator ||= World
0
         end
0
         
0
+ def create_story_runner
0
+ StoryRunner.new(scenario_runner, world_creator)
0
+ end
0
+
0
         # Use this to register a customer output formatter.
0
         def register_listener(listener)
0
           story_runner.add_listener(listener) # run_started, story_started, story_ended, #run_ended
0
@@ -40,10 +45,10 @@ module Spec
0
         end
0
         
0
         def register_exit_hook # :nodoc:
0
+ puts caller(0)[1]
0
           at_exit do
0
             exit Runner.story_runner.run_stories unless $!
0
           end
0
-
0
         end
0
         
0
         def dry_run
...
26
27
28
29
 
30
31
 
32
33
34
...
26
27
28
 
29
30
 
31
32
33
34
0
@@ -26,9 +26,9 @@ module Spec
0
           @story_file = path
0
         end
0
         
0
- def run
0
+ def run(story_runner=Spec::Story::Runner.story_runner)
0
           raise "You must set a path to the file with the story. See the RDoc." if @story_file.nil?
0
- mediator = Spec::Story::Runner::StoryMediator.new(steps, Spec::Story::Runner.story_runner, @options)
0
+ mediator = Spec::Story::Runner::StoryMediator.new(steps, story_runner, @options)
0
           parser = Spec::Story::Runner::StoryParser.new(mediator)
0
 
0
           story_text = File.read(@story_file)
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ module Spec
0
       TINY = 3
0
       RELEASE_CANDIDATE = nil
0
 
0
- BUILD_TIME_UTC = 20080325021625
0
+ BUILD_TIME_UTC = 20080328014754
0
 
0
       STRING = [MAJOR, MINOR, TINY].join('.')
0
       TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
...
22
23
24
25
26
27
 
28
29
30
31
32
33
 
 
34
35
36
37
38
 
 
 
 
 
39
40
41
42
43
44
45
46
 
47
48
49
...
51
52
53
54
 
55
56
57
...
59
60
61
62
 
63
64
65
66
67
68
 
69
70
71
...
74
75
76
77
 
78
79
80
...
83
84
85
86
 
87
88
89
...
22
23
24
 
25
 
26
27
28
29
30
31
32
33
34
35
 
 
 
 
36
37
38
39
40
41
42
43
44
 
45
46
 
47
48
49
50
...
52
53
54
 
55
56
57
58
...
60
61
62
 
63
64
65
66
67
68
 
69
70
71
72
...
75
76
77
 
78
79
80
81
...
84
85
86
 
87
88
89
90
0
@@ -22,28 +22,29 @@ module Spec
0
         
0
         it "should parse a story file" do
0
           runner = PlainTextStoryRunner.new("path")
0
-
0
           during {
0
- runner.run
0
+ runner.run(mock('runner'))
0
           }.expect {
0
             @parser.should_receive(:parse).with(["this", "and that"])
0
           }
0
         end
0
         
0
         it "should build up a mediator with its own steps and the singleton story_runner" do
0
+ @story_runner = mock('story runner', :null_object => true)
0
+
0
           runner = PlainTextStoryRunner.new("path")
0
- Spec::Story::Runner.should_receive(:story_runner).and_return(story_runner = mock("story runner"))
0
- Spec::Story::Runner::StoryMediator.should_receive(:new).with(runner.steps, story_runner, {}).
0
- and_return(mediator = stub("mediator", :run_stories => nil))
0
- runner.run
0
+
0
+ Spec::Story::Runner::StoryMediator.should_receive(:new).with(
0
+ runner.steps, @story_runner, {}
0
+ ).and_return(mediator = stub("mediator", :run_stories => nil))
0
+ runner.run(@story_runner)
0
         end
0
         
0
         it "should build up a parser with the mediator" do
0
           runner = PlainTextStoryRunner.new("path")
0
- Spec::Story::Runner.should_receive(:story_runner).and_return(story_runner = mock("story runner"))
0
           Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator = stub("mediator", :run_stories => nil))
0
           Spec::Story::Runner::StoryParser.should_receive(:new).with(mediator).and_return(@parser)
0
- runner.run
0
+ runner.run(stub("story_runner"))
0
         end
0
         
0
         it "should tell the mediator to run the stories" do
0
@@ -51,7 +52,7 @@ module Spec
0
           mediator = mock("mediator")
0
           Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator)
0
           mediator.should_receive(:run_stories)
0
- runner.run
0
+ runner.run(mock('runner'))
0
         end
0
         
0
         it "should accept a block instead of a path" do
0
@@ -59,13 +60,13 @@ module Spec
0
             runner.load("path/to/story")
0
           end
0
           File.should_receive(:read).with("path/to/story").and_return("this\nand that")
0
- runner.run
0
+ runner.run(mock('runner'))
0
         end
0
         
0
         it "should tell you if you try to run with no path set" do
0
           runner = PlainTextStoryRunner.new
0
           lambda {
0
- runner.run
0
+ runner.run(mock('runner'))
0
           }.should raise_error(RuntimeError, "You must set a path to the file with the story. See the RDoc.")
0
         end
0
         
0
@@ -74,7 +75,7 @@ module Spec
0
           Spec::Story::Runner::StoryMediator.should_receive(:new).
0
             with(anything, anything, :foo => :bar).
0
             and_return(mediator = stub("mediator", :run_stories => nil))
0
- runner.run
0
+ runner.run(mock('runner'))
0
         end
0
         
0
         it "should provide access to its options" do
0
@@ -83,7 +84,7 @@ module Spec
0
           Spec::Story::Runner::StoryMediator.should_receive(:new).
0
             with(anything, anything, :foo => :bar).
0
             and_return(mediator = stub("mediator", :run_stories => nil))
0
- runner.run
0
+ runner.run mock('runner')
0
         end
0
         
0
       end
...
47
48
49
50
 
51
52
53
...
120
121
122
123
 
124
125
126
...
47
48
49
 
50
51
52
53
...
120
121
122
 
123
124
125
126
0
@@ -47,7 +47,7 @@ module Spec
0
           @runner.scenarios.first.name.should == "scenario name"
0
           @runner.scenarios.first.story.should == @runner.stories.first
0
         end
0
-
0
+
0
         it "should create a given scenario step if one matches" do
0
           pending("need to untangle the dark mysteries of the story runner - something needs to get stubbed here") do
0
             story = @mediator.create_story "title", "narrative"
0
@@ -120,7 +120,7 @@ module Spec
0
         it "should pass options to the stories it creates" do
0
           @mediator = StoryMediator.new @step_group, @runner, :foo => :bar
0
           @mediator.create_story "story title", "story narrative"
0
-
0
+
0
           run_stories
0
           
0
           @runner.stories.first[:foo].should == :bar
...
1
 
 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
19
20
 
 
 
21
22
23
24
25
26
 
 
27
28
29
...
32
33
34
35
36
 
 
 
 
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
69
70
71
72
 
 
 
 
 
73
74
75
76
77
 
 
 
 
 
 
 
 
 
78
79
80
81
 
 
 
 
 
 
 
 
82
83
84
85
86
87
88
 
89
90
91
92
 
 
 
 
 
 
 
 
93
94
 
 
 
 
 
 
 
95
96
97
98
99
 
 
 
 
100
101
102
 
 
 
 
103
104
105
106
...
1
2
3
4
5
6
7
 
 
 
 
 
 
 
 
 
 
 
 
 
8
9
 
10
11
12
13
14
 
 
 
 
15
16
17
18
19
...
22
23
24
 
 
25
26
27
28
29
30
31
32
33
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
 
 
 
 
 
36
37
 
 
 
38
39
40
41
42
43
 
 
 
 
44
45
46
47
48
49
50
51
52
53
 
 
 
54
55
56
57
58
59
60
61
62
 
 
 
 
 
 
63
64
 
 
 
65
66
67
68
69
70
71
72
73
 
74
75
76
77
78
79
80
81
 
 
 
 
82
83
84
85
86
 
 
87
88
89
90
91
 
92
93
0
@@ -1,29 +1,19 @@
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
 
0
 module Spec
0
   module Story
0
     describe Runner, "module" do
0
- def dev_null
0
- io = StringIO.new
0
- def io.write(str)
0
- str.to_s.size
0
- end
0
- return io
0
- end
0
-
0
- before :each do
0
- Kernel.stub!(:at_exit)
0
- @stdout, $stdout = $stdout, dev_null
0
- @argv = Array.new(ARGV)
0
- @runner_module = Runner.dup
0
+ before(:each) do
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
       end
0
       
0
- after :each do
0
- $stdout = @stdout
0
- ARGV.replace @argv
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
       end
0
       
0
       it 'should wire up a singleton StoryRunner' do
0
@@ -32,75 +22,72 @@ module Spec
0
       
0
       it 'should set its options based on ARGV' do
0
         # given
0
- ARGV << '--dry-run'
0
-
0
+ @runner_module.should_receive(:run_options).and_return(
0
+ create_options(['--dry-run'])
0
+ )
0
+
0
         # when
0
         options = @runner_module.run_options
0
         
0
         # then
0
         options.dry_run.should be_true
0
       end
0
-
0
- it 'should add a reporter to the runner classes' do
0
- # given
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
-
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
-
0
- # expect
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
-
0
- # when
0
- @runner_module.story_runner
0
- end
0
       
0
- it 'should add a documenter to the runner classes if one is specified' do
0
- # given
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
         
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
+ before(:each) do
0
+ # given
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
         
0
- # expect
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
+ end
0
+
0
+ it 'should add a reporter to the runner classes' do
0
+ @runner_module.should_receive(:run_options).and_return(
0
+ create_options
0
+ )
0
         
0
- # when
0
- @runner_module.story_runner
0
- end
0
+ # expect
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
+
0
+ # when
0
+ @runner_module.story_runner
0
+ end
0
       
0
- it 'should add any registered listener to the runner classes' do
0
- # given
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
         
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
+ )
0
+
0
+ # expect
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
         
0
- listener = Object.new
0
+ # when
0
+ @runner_module.story_runner
0
+ end
0
+
0
+ it 'should add any registered listener to the runner classes' do
0
+ # given
0
+ listener = Object.new
0
         
0
- # expect
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
+ # expect
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
         
0
- # when
0
- @runner_module.register_listener listener
0
+ # when
0
+ @runner_module.register_listener listener
0
+ end
0
+ end
0
       end
0
- end
0
   end
0
 end
...
1
2
3
4
5
6
 
 
 
 
7
8
...
1
2
3
 
 
 
4
5
6
7
8
9
0
@@ -1,7 +1,8 @@
0
 require File.join(File.dirname(__FILE__), *%w[.. helper])
0
 
0
 with_steps_for :running_rspec do
0
- Dir["#{File.dirname(__FILE__)}/*"].each do |file|
0
- run file if File.file?(file) && !(file =~ /\.rb$/)
0
- end
0
+ run File.dirname(__FILE__) + "/nested_groups"
0
+ # Dir["#{File.dirname(__FILE__)}/*"].each do |file|
0
+ # run file if File.file?(file) && !(file =~ /\.rb$/)
0
+ # end
0
 end
0
\ No newline at end of file
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 module Spec
0
   module Rails
0
     module VERSION #:nodoc:
0
- BUILD_TIME_UTC = 20080325021625
0
+ BUILD_TIME_UTC = 20080328014754
0
     end
0
   end
0
 end

Comments

    No one has commented yet.