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 e81efef7089d5f1d65c49cc80395e394703e2e75

Better failure messages for a message expectation after a method stub. Fixes http://rspec.lighthouseapp.com/projects/5645/tickets/352.

Commit diff

rspec/lib/spec/mocks/message_expectation.rb

 
155155 @sym == sym and not @args_expectation.check_args(args)
156156 end
157157
158 def verify_messages_received
158 def verify_messages_received
159159 return if expected_messages_received?
160160
161161 generate_error
185185 @expected_received_count == @actual_received_count
186186 end
187187
188 def similar_messages
189 @similar_messages ||= []
190 end
191
192 def advise(args, block)
193 similar_messages << args
194 end
195
188196 def generate_error
189 @error_generator.raise_expectation_error(@sym, @expected_received_count, @actual_received_count, *@args_expectation.args)
197 if similar_messages.empty?
198 @error_generator.raise_expectation_error(@sym, @expected_received_count, @actual_received_count, *@args_expectation.args)
199 else
200 @error_generator.raise_unexpected_message_args_error(self, *@similar_messages.first)
201 end
190202 end
191203
192204 def with(*args, &block)
toggle raw diff

rspec/lib/spec/mocks/proxy.rb

 
6464 if expectation = find_matching_expectation(sym, *args)
6565 expectation.invoke(args, block)
6666 elsif stub = find_matching_method_stub(sym, *args)
67 stub.invoke([], block)
67 if expectation = find_almost_matching_expectation(sym, *args)
68 if expectation.expected_messages_received?
69 stub.invoke([], block)
70 else
71 expectation.advise(args, block)
72 stub.invoke([], block)
73 end
74 else
75 stub.invoke([], block)
76 end
6877 elsif expectation = find_almost_matching_expectation(sym, *args)
6978 raise_unexpected_message_args_error(expectation, *args) unless has_negative_expectation?(sym) unless null_object?
7079 else
toggle raw diff

rspec/lib/spec/runner/option_parser.rb

 
1919 "Separate multiple patterns with commas.",
2020 "Applies only to directories named on the command line (files",
2121 "named explicitly on the command line will be loaded regardless)."],
22 :diff => ["-D", "--diff [FORMAT]", "Show diff of objects that are expected to be equal when they are not",
22 :diff => ["-D", "--diff [FORMAT]","Show diff of objects that are expected to be equal when they are not",
2323 "Builtin formats: unified|u|context|c",
2424 "You can also specify a custom differ class",
2525 "(in which case you should also specify --require)"],
3636 :specification => ["-s", "--specification [NAME]", "DEPRECATED - use -e instead", "(This will be removed when autotest works with -e)"],
3737 :line => ["-l", "--line LINE_NUMBER", Integer, "Execute behaviout or specification at given line.",
3838 "(does not work for dynamically generated specs)"],
39 :format => ["-f", "--format FORMAT[:WHERE]", "Specifies what format to use for output. Specify WHERE to tell",
39 :format => ["-f", "--format FORMAT[:WHERE]","Specifies what format to use for output. Specify WHERE to tell",
4040 "the formatter where to write the output. All built-in formats",
4141 "expect WHERE to be a file name, and will write to STDOUT if it's",
4242 "not specified. The --format option may be specified several times",
5757 "FORMAT can also be the name of a custom formatter class",
5858 "(in which case you should also specify --require to load it)"],
5959 :require => ["-r", "--require FILE", "Require FILE before running specs",
60 "Useful for loading custom formatters or other extensions.",
61 "If this option is used it must come before the others"],
60 "Useful for loading custom formatters or other extensions.",
61 "If this option is used it must come before the others"],
6262 :backtrace => ["-b", "--backtrace", "Output full backtrace"],
6363 :loadby => ["-L", "--loadby STRATEGY", "Specify the strategy by which spec files should be loaded.",
64 "STRATEGY can currently only be 'mtime' (File modification time)",
65 "By default, spec files are loaded in alphabetical order if --loadby",
66 "is not specified."],
64 "STRATEGY can currently only be 'mtime' (File modification time)",
65 "By default, spec files are loaded in alphabetical order if --loadby",
66 "is not specified."],
6767 :reverse => ["-R", "--reverse", "Run examples in reverse order"],
6868 :timeout => ["-t", "--timeout FLOAT", "Interrupt and fail each example that doesn't complete in the",
6969 "specified time"],
107107 on(*OPTIONS[:heckle]) {|heckle| @options.load_heckle_runner(heckle)}
108108 on(*OPTIONS[:dry_run]) {@options.dry_run = true}
109109 on(*OPTIONS[:options_file]) {|options_file| parse_options_file(options_file)}
110 on(*OPTIONS[:generate_options]) do |options_file|
111 end
112 on(*OPTIONS[:runner]) do |runner|
113 @options.user_input_for_runner = runner
114 end
110 on(*OPTIONS[:generate_options]) {|options_file|}
111 on(*OPTIONS[:runner]) {|runner| @options.user_input_for_runner = runner}
115112 on(*OPTIONS[:drb]) {}
116113 on(*OPTIONS[:version]) {parse_version}
117114 on_tail(*OPTIONS[:help]) {parse_help}
176176 is_drb = false
177177 is_drb ||= argv.delete(OPTIONS[:drb][0])
178178 is_drb ||= argv.delete(OPTIONS[:drb][1])
179 return nil unless is_drb
179 return false unless is_drb
180180 @options.examples_should_not_be_run
181181 DrbCommandLine.run(
182182 self.class.parse(argv, @error_stream, @out_stream)
toggle raw diff

rspec/spec/spec/mocks/mock_spec.rb

 
8484 end
8585
8686 it "should raise exception if args don't match when method called even when the method is stubbed" do
87 pending("need to do some refactoring before trying to get this to pass")
8887 @mock.stub!(:something)
8988 @mock.should_receive(:something).with("a","b","c")
9089 lambda {
9190 @mock.something("a","d","c")
92 violated
91 @mock.rspec_verify
9392 }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
9493 end
9594
toggle raw diff

rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html

 
189189 <div class="failure" id="failure_1">
190190 <div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div>
191191 <div class="backtrace"><pre>./failing_examples/mocking_example.rb:13:
192./spec/spec/runner/formatter/html_formatter_spec.rb:25:
193./spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
194./spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
192/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
193/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
194/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
195195 <pre class="ruby"><code><span class="linenum">11</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">should fail when expected message not received</span><span class="punct">&quot;</span> <span class="keyword">do</span>
196196<span class="linenum">12</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">poke me</span><span class="punct">&quot;)</span>
197197<span class="offending"><span class="linenum">13</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span>
205205 <div class="failure" id="failure_2">
206206 <div class="message"><pre>Mock 'one two three' received :three out of order</pre></div>
207207 <div class="backtrace"><pre>./failing_examples/mocking_example.rb:22:
208./spec/spec/runner/formatter/html_formatter_spec.rb:25:
209./spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
210./spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
208/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
209/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
210/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
211211 <pre class="ruby"><code><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span>
212212<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span>
213213<span class="offending"><span class="linenum">22</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span>
221221 <div class="failure" id="failure_3">
222222 <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (no args) 0 times, but received it once</pre></div>
223223 <div class="backtrace"><pre>./failing_examples/mocking_example.rb:29:
224./spec/spec/runner/formatter/html_formatter_spec.rb:25:
225./spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
226./spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
224/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
225/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
226/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
227227 <pre class="ruby"><code><span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">don't talk to me</span><span class="punct">&quot;)</span>
228228<span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span>
229229<span class="offending"><span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span></span>
236236 <div class="failure" id="failure_4">
237237 <div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div>
238238 <div class="backtrace"><pre>./failing_examples/mocking_example.rb:33:
239./spec/spec/runner/formatter/html_formatter_spec.rb:25:
240./spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
241./spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
239/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
240/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
241/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
242242 <pre class="ruby"><code><span class="linenum">31</span>
243243<span class="linenum">32</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">has a bug we need to fix</span><span class="punct">&quot;</span> <span class="keyword">do</span>
244244<span class="offending"><span class="linenum">33</span> <span class="ident">pending</span> <span class="punct">&quot;</span><span class="string">here is the bug</span><span class="punct">&quot;</span> <span class="keyword">do</span></span>
266266 framework for Ruby
267267</pre></div>
268268 <div class="backtrace"><pre>./failing_examples/diffing_spec.rb:13:
269./spec/spec/runner/formatter/html_formatter_spec.rb:25:
270./spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
271./spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
269/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
270/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
271/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
272272 <pre class="ruby"><code><span class="linenum">11</span><span class="ident">framework</span> <span class="keyword">for</span> <span class="constant">Ruby</span>
273273<span class="linenum">12</span><span class="constant">EOF</span>
274274<span class="offending"><span class="linenum">13</span> <span class="ident">usa</span><span class="punct">.</span><span class="ident">should</span> <span class="punct">==</span> <span class="ident">uk</span></span>
297297 &gt;
298298</pre></div>
299299 <div class="backtrace"><pre>./failing_examples/diffing_spec.rb:34:
300./spec/spec/runner/formatter/html_formatter_spec.rb:25:
301./spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
302./spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
300/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
301/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
302/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
303303 <pre class="ruby"><code><span class="linenum">32</span> <span class="ident">expected</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">&quot;</span><span class="string">bob</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">giraffe</span><span class="punct">&quot;</span>
304304<span class="linenum">33</span> <span class="ident">actual</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">&quot;</span><span class="string">bob</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">tortoise</span><span class="punct">&quot;</span>
305305<span class="offending"><span class="linenum">34</span> <span class="ident">expected</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eql</span><span class="punct">(</span><span class="ident">actual</span><span class="punct">)</span></span>
toggle raw diff

rspec/spec/spec/runner/formatter/html_formatter_spec.rb

 
3333 if opt == '--diff'
3434 # Uncomment this line temporarily in order to overwrite the expected with actual.
3535 # Use with care!!!
36 File.open(expected_file, 'w') {|io| io.write(html)}
36 # File.open(expected_file, 'w') {|io| io.write(html)}
3737
3838 doc = Hpricot(html)
3939 backtraces = doc.search("div.backtrace").collect {|e| e.at("/pre").inner_html}
toggle raw diff

rspec/spec/spec/runner/option_parser_spec.rb

 
1717 options = parse(["--pattern", "foo"])
1818 options.filename_pattern.should == "foo"
1919 end
20
20
2121 it "should accept dry run option" do
2222 options = parse(["--dry-run"])
2323 options.dry_run.should be_true
2424 end
25
25
2626 it "should eval and use custom formatter when none of the builtins" do
2727 options = parse(["--format", "Custom::Formatter"])
2828 options.formatters[0].class.should be(Custom::Formatter)
4040 options.formatters[2].where.should eql("foo\\bar")
4141 options.formatters[3].where.should eql("/foo/bar")
4242 end
43
43
4444 it "should not be verbose by default" do
4545 options = parse([])
4646 options.verbose.should be_nil
4747 end
48
48
4949 it "should not use colour by default" do
5050 options = parse([])
5151 options.colour.should == false
5252 end
53
53
5454 it "should print help to stdout if no args" do
5555 pending 'A regression since 1.0.8' do
5656 options = parse([])
5858 @out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m)
5959 end
6060 end
61
61
6262 it "should print help to stdout" do
6363 options = parse(["--help"])
6464 @out.rewind
6565 @out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m)
6666 end
67
67
6868 it "should print instructions about how to require missing formatter" do
6969 lambda do
7070 options = parse(["--format", "Custom::MissingFormatter"])
7272 end.should raise_error(NameError)
7373 @err.string.should match(/Couldn't find formatter class Custom::MissingFormatter/n)
7474 end
75
75
7676 it "should print version to stdout" do
7777 options = parse(["--version"])
7878 @out.rewind
8484 parse(["--require", "whatever"])
8585 end.should raise_error(LoadError)
8686 end
87
87
8888 it "should support c option" do
8989 options = parse(["-c"])
9090 options.colour.should be_true
9191 end
92
92
9393 it "should support queens colour option" do
9494 options = parse(["--colour"])
9595 options.colour.should be_true
9696 end
97
97
9898 it "should support us color option" do
9999 options = parse(["--color"])
100100 options.colour.should be_true
101101 end
102
102
103103 it "should support single example with -e option" do
104104 options = parse(["-e", "something or other"])
105105 options.examples.should eql(["something or other"])
106106 end
107
107
108108 it "should support single example with -s option (will be removed when autotest supports -e)" do
109109 options = parse(["-s", "something or other"])
110110 options.examples.should eql(["something or other"])
111111 end
112
112
113113 it "should support single example with --example option" do
114114 options = parse(["--example", "something or other"])
115115 options.examples.should eql(["something or other"])
116116 end
117
117
118118 it "should read several example names from file if --example is given an existing file name" do
119119 options = parse(["--example", File.dirname(__FILE__) + '/examples.txt'])
120120 options.examples.should eql([
126126 options = parse(["--example", File.dirname(__FILE__) + '/empty_file.txt'])
127127 options.examples.should eql([])
128128 end
129
129
130130 it "should use html formatter when format is h" do
131131 options = parse(["--format", "h"])
132132 options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter)
133133 end
134
134
135135 it "should use html story formatter when format is h" do
136136 options = parse(["--format", "h"])
137137 options.story_formatters[0].class.should equal(Spec::Runner::Formatter::Story::HtmlFormatter)
138138 end
139
139
140140 it "should use html formatter when format is html" do
141141 options = parse(["--format", "html"])
142142 options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter)
143143 end
144
144
145145 it "should use html story formatter when format is html" do
146146 options = parse(["--format", "html"])
147147 options.story_formatters[0].class.should equal(Spec::Runner::Formatter::Story::HtmlFormatter)
148148 end
149
149
150150 it "should use html formatter with explicit output when format is html:test.html" do
151151 FileUtils.rm 'test.html' if File.exist?('test.html')
152152 options = parse(["--format", "html:test.html"])
156156 options.formatters[0].close
157157 FileUtils.rm 'test.html'
158158 end
159
159
160160 it "should use noisy backtrace tweaker with b option" do
161161 options = parse(["-b"])
162162 options.backtrace_tweaker.should be_instance_of(Spec::Runner::NoisyBacktraceTweaker)
163163 end
164
164
165165 it "should use noisy backtrace tweaker with backtrace option" do
166166 options = parse(["--backtrace"])
167167 options.backtrace_tweaker.should be_instance_of(Spec::Runner::NoisyBacktraceTweaker)
168168 end
169
169
170170 it "should use quiet backtrace tweaker by default" do
171171 options = parse([])
172172 options.backtrace_tweaker.should be_instance_of(Spec::Runner::QuietBacktraceTweaker)
173173 end
174
174
175175 it "should use progress bar formatter by default" do
176176 options = parse([])
177177 options.formatters[0].class.should equal(Spec::Runner::Formatter::ProgressBarFormatter)
178178 end
179
179
180180 it "should use specdoc formatter when format is s" do
181181 options = parse(["--format", "s"])
182182 options.formatters[0].class.should equal(Spec::Runner::Formatter::SpecdocFormatter)
183183 end
184
184
185185 it "should use specdoc formatter when format is specdoc" do
186186 options = parse(["--format", "specdoc"])
187187 options.formatters[0].class.should equal(Spec::Runner::Formatter::SpecdocFormatter)
188188 end
189
189
190190 it "should support diff option when format is not specified" do
191191 options = parse(["--diff"])
192192 options.diff_format.should == :unified
193193 end
194
194
195195 it "should use unified diff format option when format is unified" do
196196 options = parse(["--diff", "unified"])
197197 options.diff_format.should == :unified
198198 options.differ_class.should equal(Spec::Expectations::Differs::Default)
199199 end
200
200
201201 it "should use context diff format option when format is context" do
202202 options = parse(["--diff", "context"])
203203 options.diff_format.should == :context
204204 options.differ_class.should == Spec::Expectations::Differs::Default
205205 end
206
206
207207 it "should use custom diff format option when format is a custom format" do
208208 Spec::Expectations.differ.should_not be_instance_of(Custom::Differ)
209
209
210210 options = parse(["--diff", "Custom::Differ"])
211211 options.parse_diff "Custom::Differ"
212212 options.diff_format.should == :custom
213213 options.differ_class.should == Custom::Differ
214214 Spec::Expectations.differ.should be_instance_of(Custom::Differ)
215215 end
216
216
217217 it "should print instructions about how to fix missing differ" do
218218 lambda { parse(["--diff", "Custom::MissingFormatter"]) }.should raise_error(NameError)
219219 @err.string.should match(/Couldn't find differ class Custom::MissingFormatter/n)
220220 end
221
221
222222 describe "when attempting a focussed spec" do
223223 attr_reader :file, :dir
224224 before do
226226 @file = "#{File.dirname(__FILE__)}/spec_parser/spec_parser_fixture.rb"
227227 @dir = File.dirname(file)
228228 end
229
229
230230 after do
231231 $rspec_options = @original_rspec_options
232232 end
233
233
234234 def parse(args)
235235 options = super
236236 $rspec_options = options
237237 options.filename_pattern = "*_fixture.rb"
238238 options
239239 end
240
240
241241 it "should support --line to identify spec" do
242242 options = parse([file, "--line", "13"])
243243 options.line_number.should == 13
245245 options.run_examples
246246 options.examples.should eql(["d"])
247247 end
248
248
249249 it "should fail with error message if file is dir along with --line" do
250250 options = parse([dir, "--line", "169"])
251251 options.line_number.should == 169
252252 options.run_examples
253253 @err.string.should match(/You must specify one file, not a directory when using the --line option/n)
254254 end
255
255
256256 it "should fail with error message if file does not exist along with --line" do
257257 options = parse(["some file", "--line", "169"])
258258 proc do
259259 options.run_examples
260260 end.should raise_error
261261 end
262
262
263263 it "should fail with error message if more than one files are specified along with --line" do
264264 options = parse([file, file, "--line", "169"])
265265 options.run_examples
266266 @err.string.should match(/Only one file can be specified when using the --line option/n)
267267 end
268
268
269269 it "should fail with error message if --example and --line are used simultaneously" do
270270 options = parse([file, "--example", "some example", "--line", "169"])
271271 options.run_examples
272272 @err.string.should match(/You cannot use both --line and --example/n)
273273 end
274274 end
275
275
276276 if [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM}
277277 it "should barf when --heckle is specified (and platform is windows)" do
278278 lambda do
285285 options.heckle_runner.should be_instance_of(Spec::Runner::HeckleRunner)
286286 end
287287 end
288
288
289289 it "should read options from file when --options is specified" do
290290 options = parse(["--options", File.dirname(__FILE__) + "/spec.opts"])
291291 options.diff_format.should_not be_nil
292292 options.colour.should be_true
293293 end
294
294
295295 it "should default the formatter to ProgressBarFormatter when using options file" do
296296 options = parse(["--options", File.dirname(__FILE__) + "/spec.opts"])
297297 options.formatters.first.should be_instance_of(::Spec::Runner::Formatter::ProgressBarFormatter)
299299
300300 it "should run parse drb after parsing options" do
301301 @parser.stub!(:parse_drb)
302 @parser.should_receive(:parse_drb).with(["--drb"])
303 options = parse(["--options", File.dirname(__FILE__) + "/spec_drb.opts"])
302 @parser.should_receive(:parse_drb).with(["--drb"]).and_return(true)
303 options = parse(["--options", File.dirname(__FILE__) + "/spec_drb.opts"])
304304 end
305305
306306 it "should read spaced and multi-line options from file when --options is specified" do
316316 IO.read('test.spec.opts').should == "--colour\n--diff\n"
317317 FileUtils.rm 'test.spec.opts'
318318 end
319
319
320320 it "should save config to file when -G is specified" do
321321 FileUtils.rm 'test.spec.opts' if File.exist?('test.spec.opts')
322322 options = parse(["--colour", "-G", "test.spec.opts", "--diff"])
323323 IO.read('test.spec.opts').should == "--colour\n--diff\n"
324324 FileUtils.rm 'test.spec.opts'
325325 end
326
326
327327 it "when --drb is specified, calls DrbCommandLine all of the other ARGV arguments" do
328328 options = Spec::Runner::OptionParser.parse([
329329 "some/spec.rb", "--diff", "--colour"
337337 it "should reverse spec order when --reverse is specified" do
338338 options = parse(["some/spec.rb", "--reverse"])
339339 end
340
340
341341 it "should set an mtime comparator when --loadby mtime" do
342342 options = parse(["--loadby", 'mtime'])
343343 runner = Spec::Runner::ExampleGroupRunner.new(options)
345345 with(options).
346346 and_return(runner)
347347 runner.should_receive(:load_files).with(["most_recent_spec.rb", "command_line_spec.rb"])
348
348
349349 Dir.chdir(File.dirname(__FILE__)) do
350350 options.files << 'command_line_spec.rb'
351351 options.files << 'most_recent_spec.rb'