rspec-core 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. data/Gemfile +16 -11
  2. data/History.markdown +22 -0
  3. data/License.txt +2 -1
  4. data/{README.markdown → README.md} +11 -3
  5. data/Rakefile +1 -0
  6. data/Upgrade.markdown +35 -2
  7. data/features/hooks/around_hooks.feature +18 -2
  8. data/lib/rspec/core/configuration.rb +38 -36
  9. data/lib/rspec/core/configuration_options.rb +2 -1
  10. data/lib/rspec/core/deprecation.rb +1 -1
  11. data/lib/rspec/core/example.rb +19 -9
  12. data/lib/rspec/core/example_group.rb +14 -26
  13. data/lib/rspec/core/extensions/kernel.rb +23 -3
  14. data/lib/rspec/core/formatters/base_text_formatter.rb +43 -30
  15. data/lib/rspec/core/formatters/documentation_formatter.rb +1 -1
  16. data/lib/rspec/core/formatters/html_formatter.rb +10 -8
  17. data/lib/rspec/core/hooks.rb +2 -2
  18. data/lib/rspec/core/metadata.rb +46 -34
  19. data/lib/rspec/core/option_parser.rb +2 -2
  20. data/lib/rspec/core/rake_task.rb +1 -1
  21. data/lib/rspec/core/ruby_project.rb +2 -2
  22. data/lib/rspec/core/runner.rb +2 -2
  23. data/lib/rspec/core/subject.rb +4 -3
  24. data/lib/rspec/core/version.rb +1 -1
  25. data/rspec-core.gemspec +1 -1
  26. data/spec/rspec/core/configuration_options_spec.rb +7 -5
  27. data/spec/rspec/core/configuration_spec.rb +58 -69
  28. data/spec/rspec/core/example_group_spec.rb +22 -7
  29. data/spec/rspec/core/example_spec.rb +1 -1
  30. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +2 -2
  31. data/spec/rspec/core/kernel_extensions_spec.rb +6 -3
  32. data/spec/rspec/core/metadata_spec.rb +13 -0
  33. data/spec/rspec/core/pending_example_spec.rb +1 -1
  34. data/spec/rspec/core/rake_task_spec.rb +2 -3
  35. data/spec/spec_helper.rb +1 -0
  36. metadata +9 -11
  37. data/.treasure_map.rb +0 -23
  38. data/specs.watchr +0 -58
@@ -7,11 +7,26 @@ module RSpec::Core
7
7
  let(:config) { subject }
8
8
 
9
9
  describe "#load_spec_files" do
10
+
10
11
  it "loads files using load" do
11
12
  config.files_to_run = ["foo.bar", "blah_spec.rb"]
12
13
  config.should_receive(:load).twice
13
14
  config.load_spec_files
14
15
  end
16
+
17
+ context "with rspec-1 loaded" do
18
+ before do
19
+ Object.const_set(:Spec, Module.new)
20
+ ::Spec::const_set(:VERSION, Module.new)
21
+ ::Spec::VERSION::const_set(:MAJOR, 1)
22
+ end
23
+ after { Object.__send__(:remove_const, :Spec) }
24
+ it "raises with a helpful message" do
25
+ expect {
26
+ config.load_spec_files
27
+ }.to raise_error(/rspec-1 has been loaded/)
28
+ end
29
+ end
15
30
  end
16
31
 
17
32
  describe "mock_framework" do
@@ -226,12 +241,12 @@ module RSpec::Core
226
241
  describe "run_all_when_everything_filtered?" do
227
242
 
228
243
  it "defaults to false" do
229
- config.run_all_when_everything_filtered?.should == false
244
+ config.run_all_when_everything_filtered?.should be_false
230
245
  end
231
246
 
232
247
  it "can be queried with question method" do
233
248
  config.run_all_when_everything_filtered = true
234
- config.run_all_when_everything_filtered?.should == true
249
+ config.run_all_when_everything_filtered?.should be_true
235
250
  end
236
251
  end
237
252
 
@@ -241,7 +256,7 @@ module RSpec::Core
241
256
  it "does not set color_enabled" do
242
257
  config.output_stream = StringIO.new
243
258
  config.output_stream.stub(:tty?) { false }
244
- config.autotest = false
259
+ config.tty = false
245
260
  config.color_enabled = true
246
261
  config.color_enabled.should be_false
247
262
  end
@@ -251,17 +266,17 @@ module RSpec::Core
251
266
  it "does not set color_enabled" do
252
267
  config.output_stream = StringIO.new
253
268
  config.output_stream.stub(:tty?) { true }
254
- config.autotest = false
269
+ config.tty = false
255
270
  config.color_enabled = true
256
271
  config.color_enabled.should be_true
257
272
  end
258
273
  end
259
274
 
260
- context "with autotest output" do
275
+ context "with tty set" do
261
276
  it "does not set color_enabled" do
262
277
  config.output_stream = StringIO.new
263
278
  config.output_stream.stub(:tty?) { false }
264
- config.autotest = true
279
+ config.tty = true
265
280
  config.color_enabled = true
266
281
  config.color_enabled.should be_true
267
282
  end
@@ -270,75 +285,47 @@ module RSpec::Core
270
285
  context "on windows" do
271
286
  before do
272
287
  @original_host = RbConfig::CONFIG['host_os']
273
- @original_stdout = $stdout
274
- @original_stderr = $stderr
275
- RbConfig::CONFIG['host_os'] = 'mswin'
288
+ RbConfig::CONFIG['host_os'] = 'mingw'
276
289
  config.stub(:require)
277
290
  config.stub(:warn)
278
291
  end
279
292
 
280
293
  after do
281
294
  RbConfig::CONFIG['host_os'] = @original_host
282
- $stdout = @original_stdout
283
- $stderr = @original_stderr
284
295
  end
285
296
 
286
- context "with win32console available" do
287
- it "requires win32console" do
288
- config.should_receive(:require).
289
- with("Win32/Console/ANSI")
290
- config.color_enabled = true
297
+ context "with ANSICON available" do
298
+ before(:all) do
299
+ @original_ansicon = ENV['ANSICON']
300
+ ENV['ANSICON'] = 'ANSICON'
291
301
  end
292
302
 
293
- context "with $stdout/err assigned to config.output/error_stream" do
294
- it "reassigns new $stdout to output_stream" do
295
- config.output_stream = $stdout
296
- substitute_stdout = StringIO.new
297
- config.stub(:require) do |what|
298
- $stdout = substitute_stdout if what =~ /Win32/
299
- end
300
- config.color_enabled = true
301
- config.output_stream.should eq(substitute_stdout)
302
- end
303
-
304
- it "reassigns new $stderr to error_stream" do
305
- config.error_stream = $stderr
306
- substitute_stderr = StringIO.new
307
- config.stub(:require) do |what|
308
- $stderr = substitute_stderr if what =~ /Win32/
309
- end
310
- config.color_enabled = true
311
- config.error_stream.should eq(substitute_stderr)
312
- end
303
+ after(:all) do
304
+ ENV['ANSICON'] = @original_ansicon
305
+ end
306
+
307
+ it "enables colors" do
308
+ config.output_stream = StringIO.new
309
+ config.output_stream.stub(:tty?) { true }
310
+ config.color_enabled = true
311
+ config.color_enabled.should be_true
313
312
  end
314
313
 
315
- context "without $stdout/err assigned to config.output/error_stream" do
316
- it "leaves output stream intact" do
317
- config.output_stream = output_stream = StringIO.new
318
- config.stub(:require) do |what|
319
- $stdout = StringIO.new if what =~ /Win32/
320
- end
321
- config.color_enabled = true
322
- config.output_stream.should eq(output_stream)
323
- end
324
-
325
- it "leaves error stream intact" do
326
- config.error_stream = error_stream = StringIO.new
327
- config.stub(:require) do |what|
328
- $stderr = StringIO.new if what =~ /Win32/
329
- end
330
- config.color_enabled = true
331
- config.error_stream.should eq(error_stream)
314
+ it "leaves output stream intact" do
315
+ config.output_stream = $stdout
316
+ config.stub(:require) do |what|
317
+ config.output_stream = 'foo' if what =~ /Win32/
332
318
  end
319
+ config.color_enabled = true
320
+ config.output_stream.should eq($stdout)
333
321
  end
334
-
335
322
  end
336
323
 
337
- context "with win32console NOT available" do
338
- it "warns to install win32console" do
324
+ context "with ANSICON NOT available" do
325
+ it "warns to install ANSICON" do
339
326
  config.stub(:require) { raise LoadError }
340
327
  config.should_receive(:warn).
341
- with(/You must 'gem install win32console'/)
328
+ with(/You must use ANSICON/)
342
329
  config.color_enabled = true
343
330
  end
344
331
 
@@ -516,20 +503,13 @@ module RSpec::Core
516
503
  end
517
504
  end
518
505
 
519
- describe "#debug=true" do
520
- it "requires 'ruby-debug'" do
521
- config.should_receive(:require).with('ruby-debug')
506
+ describe "#debug=" do
507
+ it "is deprecated" do
508
+ RSpec.should_receive(:warn_deprecation)
522
509
  config.debug = true
523
510
  end
524
511
  end
525
512
 
526
- describe "#debug=false" do
527
- it "does not require 'ruby-debug'" do
528
- config.should_not_receive(:require).with('ruby-debug')
529
- config.debug = false
530
- end
531
- end
532
-
533
513
  describe "#output=" do
534
514
  it "sets the output" do
535
515
  output = mock("output")
@@ -623,7 +603,7 @@ module RSpec::Core
623
603
  end
624
604
 
625
605
  describe "#configure_group" do
626
- it "extends with modules" do
606
+ it "extends with 'extend'" do
627
607
  mod = Module.new
628
608
  group = ExampleGroup.describe("group", :foo => :bar)
629
609
 
@@ -632,7 +612,7 @@ module RSpec::Core
632
612
  group.should be_a(mod)
633
613
  end
634
614
 
635
- it "includes modules" do
615
+ it "extends with 'module'" do
636
616
  mod = Module.new
637
617
  group = ExampleGroup.describe("group", :foo => :bar)
638
618
 
@@ -641,6 +621,15 @@ module RSpec::Core
641
621
  group.included_modules.should include(mod)
642
622
  end
643
623
 
624
+ it "requires only one matching filter" do
625
+ mod = Module.new
626
+ group = ExampleGroup.describe("group", :foo => :bar)
627
+
628
+ config.include(mod, :foo => :bar, :baz => :bam)
629
+ config.configure_group(group)
630
+ group.included_modules.should include(mod)
631
+ end
632
+
644
633
  it "includes each one before deciding whether to include the next" do
645
634
  mod1 = Module.new do
646
635
  def self.included(host)
@@ -176,6 +176,21 @@ module RSpec::Core
176
176
  end
177
177
  end
178
178
 
179
+ context "in a nested group" do
180
+ it "inherits the described class/module from the outer group" do
181
+ group = ExampleGroup.describe(String) do
182
+ describe Array do
183
+ example "desribes is String" do
184
+ described_class.should eq(String)
185
+ end
186
+ end
187
+ end
188
+
189
+ group.run.should be_true, "expected examples in group to pass"
190
+ end
191
+ end
192
+
193
+
179
194
  end
180
195
 
181
196
  describe '#described_class' do
@@ -359,7 +374,7 @@ module RSpec::Core
359
374
  example = group.example("equality") { 1.should == 2}
360
375
  group.run
361
376
 
362
- example.metadata[:execution_result][:exception_encountered].message.should == "error in before each"
377
+ example.metadata[:execution_result][:exception].message.should == "error in before each"
363
378
  end
364
379
 
365
380
  it "treats an error in before(:all) as a failure" do
@@ -370,8 +385,8 @@ module RSpec::Core
370
385
 
371
386
  example.metadata.should_not be_nil
372
387
  example.metadata[:execution_result].should_not be_nil
373
- example.metadata[:execution_result][:exception_encountered].should_not be_nil
374
- example.metadata[:execution_result][:exception_encountered].message.should == "error in before all"
388
+ example.metadata[:execution_result][:exception].should_not be_nil
389
+ example.metadata[:execution_result][:exception].message.should == "error in before all"
375
390
  end
376
391
 
377
392
  it "treats an error in before(:all) as a failure for a spec in a nested group" do
@@ -387,8 +402,8 @@ module RSpec::Core
387
402
 
388
403
  example.metadata.should_not be_nil
389
404
  example.metadata[:execution_result].should_not be_nil
390
- example.metadata[:execution_result][:exception_encountered].should_not be_nil
391
- example.metadata[:execution_result][:exception_encountered].message.should == "error in before all"
405
+ example.metadata[:execution_result][:exception].should_not be_nil
406
+ example.metadata[:execution_result][:exception].message.should == "error in before all"
392
407
  end
393
408
 
394
409
  context "when an error occurs in an after(:all) hook" do
@@ -492,8 +507,8 @@ module RSpec::Core
492
507
  describe Object, "describing nested example_groups", :little_less_nested => 'yep' do
493
508
 
494
509
  describe "A sample nested group", :nested_describe => "yep" do
495
- it "sets the described class to the constant Object" do
496
- example.example_group.describes.should == Object
510
+ it "sets the described class to the described class of the outer most group" do
511
+ example.example_group.describes.should eq(ExampleGroup)
497
512
  end
498
513
 
499
514
  it "sets the description to 'A sample nested describe'" do
@@ -82,7 +82,7 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
82
82
 
83
83
  group.run
84
84
 
85
- example.metadata[:execution_result][:exception_encountered].message.should == "FOO"
85
+ example.metadata[:execution_result][:exception].message.should == "FOO"
86
86
  end
87
87
  end
88
88
 
@@ -8,11 +8,11 @@ module RSpec::Core::Formatters
8
8
  examples = [
9
9
  double("example 1",
10
10
  :description => "first example",
11
- :execution_result => {:status => 'failed', :exception_encountered => Exception.new }
11
+ :execution_result => {:status => 'failed', :exception => Exception.new }
12
12
  ),
13
13
  double("example 2",
14
14
  :description => "second example",
15
- :execution_result => {:status => 'failed', :exception_encountered => Exception.new }
15
+ :execution_result => {:status => 'failed', :exception => Exception.new }
16
16
  )
17
17
  ]
18
18
 
@@ -1,9 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "extensions" do
4
- describe "debugger" do
5
- it "is defined on Kernel" do
6
- Kernel.should respond_to(:debugger)
4
+ describe "#debugger" do
5
+ it "warns if ruby-debug is not installed" do
6
+ object = Object.new
7
+ object.should_receive(:warn).with(/debugger .* ignored:\n.* ruby-debug/m)
8
+ object.stub(:require) { raise LoadError }
9
+ object.__send__ :method_missing, :debugger
7
10
  end
8
11
  end
9
12
  end
@@ -157,6 +157,19 @@ module RSpec
157
157
  m[:example_group][:describes].should be(String)
158
158
  end
159
159
  end
160
+
161
+ context "with describes from a superclass metadata" do
162
+ it "returns the superclass' described class" do
163
+ sm = Metadata.new
164
+ sm.process(String)
165
+
166
+ m = Metadata.new(sm)
167
+ m.process(Array)
168
+
169
+ m = m.for_example("example", {})
170
+ m[:example_group][:describes].should be(String)
171
+ end
172
+ end
160
173
  end
161
174
 
162
175
  describe ":description" do
@@ -24,7 +24,7 @@ RSpec::Matchers.define :fail_with do |exception_klass|
24
24
  case
25
25
  when example.metadata[:pending] then "was pending"
26
26
  when result[:status] != 'failed' then result[:status]
27
- when !result[:exception_encountered].is_a?(exception_klass) then "failed with a #{result[:exception_encountered].class}"
27
+ when !result[:exception].is_a?(exception_klass) then "failed with a #{result[:exception].class}"
28
28
  else nil
29
29
  end
30
30
  end
@@ -97,11 +97,10 @@ module RSpec::Core
97
97
  spec_command.should =~ /rcov.*--exclude "mocks"/
98
98
  end
99
99
 
100
- it "ensures that -Ispec and -Ilib are in the resulting command" do
100
+ it "ensures that -Ispec:lib is in the resulting command" do
101
101
  task.rcov = true
102
102
  task.rcov_opts = '--exclude "mocks"'
103
- spec_command.should =~ /rcov.*-Ispec/
104
- spec_command.should =~ /rcov.*-Ilib/
103
+ spec_command.should =~ /rcov.*-Ispec:lib/
105
104
  end
106
105
  end
107
106
  end
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,7 @@ require 'autotest/rspec2'
4
4
  Dir['./spec/support/**/*.rb'].map {|f| require f}
5
5
 
6
6
  class NullObject
7
+ private
7
8
  def method_missing(method, *args, &block)
8
9
  # ignore
9
10
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 2
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 2.1.0
9
+ version: 2.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Chad Humphries
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-07 01:00:00 -05:00
18
+ date: 2010-11-28 00:00:00 -06:00
19
19
  default_executable: rspec
20
20
  dependencies: []
21
21
 
@@ -27,16 +27,15 @@ executables:
27
27
  extensions: []
28
28
 
29
29
  extra_rdoc_files:
30
- - README.markdown
30
+ - README.md
31
31
  files:
32
32
  - .document
33
33
  - .gitignore
34
- - .treasure_map.rb
35
34
  - Gemfile
36
35
  - Guardfile
37
36
  - History.markdown
38
37
  - License.txt
39
- - README.markdown
38
+ - README.md
40
39
  - Rakefile
41
40
  - Upgrade.markdown
42
41
  - autotest/discover.rb
@@ -179,7 +178,6 @@ files:
179
178
  - spec/ruby_forker.rb
180
179
  - spec/spec_helper.rb
181
180
  - spec/support/matchers.rb
182
- - specs.watchr
183
181
  has_rdoc: true
184
182
  homepage: http://github.com/rspec/rspec-core
185
183
  licenses: []
@@ -187,7 +185,7 @@ licenses: []
187
185
  post_install_message: |
188
186
  **************************************************
189
187
 
190
- Thank you for installing rspec-core-2.1.0
188
+ Thank you for installing rspec-core-2.2.0
191
189
 
192
190
  Please be sure to look at the upgrade instructions to see what might have
193
191
  changed since the last release:
@@ -205,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
203
  requirements:
206
204
  - - ">="
207
205
  - !ruby/object:Gem::Version
208
- hash: -2874414525307202279
206
+ hash: -1519645400680950494
209
207
  segments:
210
208
  - 0
211
209
  version: "0"
@@ -214,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
212
  requirements:
215
213
  - - ">="
216
214
  - !ruby/object:Gem::Version
217
- hash: -2874414525307202279
215
+ hash: -1519645400680950494
218
216
  segments:
219
217
  - 0
220
218
  version: "0"
@@ -224,7 +222,7 @@ rubyforge_project: rspec
224
222
  rubygems_version: 1.3.7
225
223
  signing_key:
226
224
  specification_version: 3
227
- summary: rspec-core-2.1.0
225
+ summary: rspec-core-2.2.0
228
226
  test_files:
229
227
  - features/README.markdown
230
228
  - features/command_line/configure.feature