rspec-core 2.11.0 → 2.11.1

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.
@@ -1,3 +1,18 @@
1
+ ### 2.11.1 / 2012-07-18
2
+ [full changelog](http://github.com/rspec/rspec-core/compare/v2.11.0...v2.11.1)
3
+
4
+ Bug fixes
5
+
6
+ * Fix the way we autoload RSpec::Matchers so that custom matchers can be
7
+ defined before rspec-core has been configured to definitely use
8
+ rspec-expectations. (Myron Marston)
9
+ * Fix typo in --help message printed for -e option. (Jo Liss)
10
+ * Fix ruby warnings. (Myron Marston)
11
+ * Ignore mock expectation failures when the example has already failed.
12
+ Mock expectation failures have always been ignored in this situation,
13
+ but due to my changes in 27059bf1 it was printing a confusing message.
14
+ (Myron Marston).
15
+
1
16
  ### 2.11.0 / 2012-07-07
2
17
  [full changelog](http://github.com/rspec/rspec-core/compare/v2.10.1...v2.11.0)
3
18
 
@@ -13,6 +13,22 @@ Feature: configure expectation framework
13
13
  provide a description to every example. You cannot rely on the generated
14
14
  descriptions provided by rspec-expectations.
15
15
 
16
+ Scenario: rspec-expectations can be used by default if nothing is configured
17
+ Given a file named "example_spec.rb" with:
18
+ """
19
+ RSpec::Matchers.define :be_a_multiple_of do |factor|
20
+ match do |actual|
21
+ actual % factor == 0
22
+ end
23
+ end
24
+
25
+ describe 6 do
26
+ it { should be_a_multiple_of(3) }
27
+ end
28
+ """
29
+ When I run `rspec example_spec.rb`
30
+ Then the examples should all pass
31
+
16
32
  Scenario: configure rspec-expectations (explicitly)
17
33
  Given a file named "example_spec.rb" with:
18
34
  """
@@ -40,7 +40,6 @@ require_rspec 'core/example_group'
40
40
  require_rspec 'core/version'
41
41
 
42
42
  module RSpec
43
- autoload :Matchers, 'rspec/matchers'
44
43
  autoload :SharedContext, 'rspec/core/shared_context'
45
44
 
46
45
  # @private
@@ -106,6 +105,22 @@ module RSpec
106
105
 
107
106
  module Core
108
107
  end
108
+
109
+ def self.const_missing(name)
110
+ case name
111
+ when :Matchers
112
+ # Load rspec-expectations when RSpec::Matchers is referenced. This allows
113
+ # people to define custom matchers (using `RSpec::Matchers.define`) before
114
+ # rspec-core has loaded rspec-expectations (since it delays the loading of
115
+ # it to allow users to configure a different assertion/expectation
116
+ # framework). `autoload` can't be used since it works with ruby's built-in
117
+ # require (e.g. for files that are available relative to a load path dir),
118
+ # but not with rubygems' extended require.
119
+ require 'rspec/expectations'
120
+ ::RSpec::Matchers
121
+ else super
122
+ end
123
+ end
109
124
  end
110
125
 
111
126
  require_rspec 'core/backward_compatibility'
@@ -205,7 +205,7 @@ module RSpec
205
205
  # Used internally to set an exception in an after hook, which
206
206
  # captures the exception but doesn't raise it.
207
207
  def set_exception(exception, context=nil)
208
- if @exception
208
+ if @exception && context != :dont_print
209
209
  # An error has already been set; we don't want to override it,
210
210
  # but we also don't want silence the error, so let's print it.
211
211
  msg = <<-EOS
@@ -301,13 +301,19 @@ An error occurred #{context}
301
301
 
302
302
  def run_after_each
303
303
  @example_group_class.run_after_each_hooks(self)
304
- @example_group_instance.verify_mocks_for_rspec
304
+ verify_mocks
305
305
  rescue Exception => e
306
306
  set_exception(e, "in an after(:each) hook")
307
307
  ensure
308
308
  @example_group_instance.teardown_mocks_for_rspec
309
309
  end
310
310
 
311
+ def verify_mocks
312
+ @example_group_instance.verify_mocks_for_rspec
313
+ rescue Exception => e
314
+ set_exception(e, :dont_print)
315
+ end
316
+
311
317
  def assign_generated_description
312
318
  return unless RSpec.configuration.expecting_with_rspec?
313
319
  if metadata[:description].empty? and !pending?
@@ -134,8 +134,8 @@ FILTERING
134
134
  options[:pattern] = o
135
135
  end
136
136
 
137
- parser.on('-e', '--example STRING', "Run examples whose full nested names include STRING (may be',
138
- ' used more than once)") do |o|
137
+ parser.on('-e', '--example STRING', "Run examples whose full nested names include STRING (may be",
138
+ " used more than once)") do |o|
139
139
  (options[:full_description] ||= []) << Regexp.compile(Regexp.escape(o))
140
140
  end
141
141
 
@@ -38,7 +38,7 @@ module RSpec
38
38
  unless args.empty?
39
39
  mod = Module.new
40
40
  (class << mod; self; end).send :define_method, :extended do |host|
41
- host.class_eval &block
41
+ host.class_eval(&block)
42
42
  end
43
43
  RSpec.configuration.extend mod, *args
44
44
  end
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Core
3
3
  module Version
4
- STRING = '2.11.0'
4
+ STRING = '2.11.1'
5
5
  end
6
6
  end
7
7
  end
@@ -83,7 +83,7 @@ module RSpec::Core
83
83
  lambda do
84
84
  config.send m, mod do |mod_config|
85
85
  end
86
- end.should raise_error /must respond to `configuration`/
86
+ end.should raise_error(/must respond to `configuration`/)
87
87
  end
88
88
  end
89
89
 
@@ -179,7 +179,7 @@ module RSpec::Core
179
179
  lambda do
180
180
  config.expect_with :rspec, :stdlib do |mod_config|
181
181
  end
182
- end.should raise_error /expect_with only accepts/
182
+ end.should raise_error(/expect_with only accepts/)
183
183
  end
184
184
 
185
185
  it "raises ArgumentError if framework is not supported" do
@@ -259,37 +259,48 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
259
259
  end
260
260
  end
261
261
 
262
- context "when the example and an around hook raise errors" do
263
- it "prints the around hook error rather than silencing it" do
264
- group = RSpec::Core::ExampleGroup.describe do
265
- around(:each) { |e| e.run; raise "around" }
266
- example("e") { raise "example" }
267
- end
268
-
262
+ context 'when the example raises an error' do
263
+ def run_and_capture_reported_message(group)
269
264
  reported_msg = nil
270
265
  # We can't use should_receive(:message).with(/.../) here,
271
266
  # because if that fails, it would fail within our example-under-test,
272
267
  # and since there's already two errors, it would just be reported again.
273
268
  RSpec.configuration.reporter.stub(:message) { |msg| reported_msg = msg }
274
269
  group.run
275
- reported_msg.should =~ /An error occurred in an around.* hook/i
270
+ reported_msg
271
+ end
272
+
273
+ it "prints any around hook errors rather than silencing them" do
274
+ group = RSpec::Core::ExampleGroup.describe do
275
+ around(:each) { |e| e.run; raise "around" }
276
+ example("e") { raise "example" }
277
+ end
278
+
279
+ message = run_and_capture_reported_message(group)
280
+ message.should =~ /An error occurred in an around.* hook/i
276
281
  end
277
- end
278
282
 
279
- context "when the example and an after hook raise errors" do
280
- it "prints the after hook error rather than silencing it" do
283
+ it "prints any after hook errors rather than silencing them" do
281
284
  group = RSpec::Core::ExampleGroup.describe do
282
285
  after(:each) { raise "after" }
283
286
  example("e") { raise "example" }
284
287
  end
285
288
 
286
- reported_msg = nil
287
- # We can't use should_receive(:message).with(/.../) here,
288
- # because if that fails, it would fail within our example-under-test,
289
- # and since there's already two errors, it would just be reported again.
290
- RSpec.configuration.reporter.stub(:message) { |msg| reported_msg = msg }
291
- group.run
292
- reported_msg.should =~ /An error occurred in an after.* hook/i
289
+ message = run_and_capture_reported_message(group)
290
+ message.should =~ /An error occurred in an after.* hook/i
291
+ end
292
+
293
+ it 'does not print mock expectation errors' do
294
+ group = RSpec::Core::ExampleGroup.describe do
295
+ example do
296
+ foo = mock
297
+ foo.should_receive(:bar)
298
+ raise "boom"
299
+ end
300
+ end
301
+
302
+ message = run_and_capture_reported_message(group)
303
+ message.should be_nil
293
304
  end
294
305
  end
295
306
  end
@@ -68,7 +68,7 @@ module RSpec::Core
68
68
  describe option do
69
69
  it "escapes the arg" do
70
70
  options = Parser.parse!([option, "this (and that)"])
71
- options[:full_description].length.should == 1
71
+ options[:full_description].length.should eq(1)
72
72
  "this (and that)".should match(options[:full_description].first)
73
73
  end
74
74
  end
metadata CHANGED
@@ -1,186 +1,194 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rspec-core
3
- version: !ruby/object:Gem::Version
4
- version: 2.11.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 33
5
5
  prerelease:
6
+ segments:
7
+ - 2
8
+ - 11
9
+ - 1
10
+ version: 2.11.1
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Steven Baker
9
14
  - David Chelimsky
10
15
  - Chad Humphries
11
16
  autorequire:
12
17
  bindir: exe
13
18
  cert_chain: []
14
- date: 2012-07-07 00:00:00.000000000 Z
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
19
+
20
+ date: 2012-07-19 00:00:00 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
17
23
  name: rake
18
- requirement: !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ~>
22
- - !ruby/object:Gem::Version
23
- version: 0.9.2
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
26
+ version_requirements: &id001 !ruby/object:Gem::Requirement
27
27
  none: false
28
- requirements:
28
+ requirements:
29
29
  - - ~>
30
- - !ruby/object:Gem::Version
30
+ - !ruby/object:Gem::Version
31
+ hash: 63
32
+ segments:
33
+ - 0
34
+ - 9
35
+ - 2
31
36
  version: 0.9.2
32
- - !ruby/object:Gem::Dependency
37
+ requirement: *id001
38
+ - !ruby/object:Gem::Dependency
33
39
  name: cucumber
34
- requirement: !ruby/object:Gem::Requirement
35
- none: false
36
- requirements:
37
- - - ~>
38
- - !ruby/object:Gem::Version
39
- version: 1.1.9
40
40
  type: :development
41
41
  prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
42
+ version_requirements: &id002 !ruby/object:Gem::Requirement
43
43
  none: false
44
- requirements:
44
+ requirements:
45
45
  - - ~>
46
- - !ruby/object:Gem::Version
46
+ - !ruby/object:Gem::Version
47
+ hash: 1
48
+ segments:
49
+ - 1
50
+ - 1
51
+ - 9
47
52
  version: 1.1.9
48
- - !ruby/object:Gem::Dependency
53
+ requirement: *id002
54
+ - !ruby/object:Gem::Dependency
49
55
  name: aruba
50
- requirement: !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ~>
54
- - !ruby/object:Gem::Version
55
- version: 0.4.11
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: !ruby/object:Gem::Requirement
58
+ version_requirements: &id003 !ruby/object:Gem::Requirement
59
59
  none: false
60
- requirements:
60
+ requirements:
61
61
  - - ~>
62
- - !ruby/object:Gem::Version
62
+ - !ruby/object:Gem::Version
63
+ hash: 25
64
+ segments:
65
+ - 0
66
+ - 4
67
+ - 11
63
68
  version: 0.4.11
64
- - !ruby/object:Gem::Dependency
69
+ requirement: *id003
70
+ - !ruby/object:Gem::Dependency
65
71
  name: ZenTest
66
- requirement: !ruby/object:Gem::Requirement
67
- none: false
68
- requirements:
69
- - - '='
70
- - !ruby/object:Gem::Version
71
- version: 4.6.2
72
72
  type: :development
73
73
  prerelease: false
74
- version_requirements: !ruby/object:Gem::Requirement
74
+ version_requirements: &id004 !ruby/object:Gem::Requirement
75
75
  none: false
76
- requirements:
77
- - - '='
78
- - !ruby/object:Gem::Version
76
+ requirements:
77
+ - - "="
78
+ - !ruby/object:Gem::Version
79
+ hash: 35
80
+ segments:
81
+ - 4
82
+ - 6
83
+ - 2
79
84
  version: 4.6.2
80
- - !ruby/object:Gem::Dependency
85
+ requirement: *id004
86
+ - !ruby/object:Gem::Dependency
81
87
  name: nokogiri
82
- requirement: !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - '='
86
- - !ruby/object:Gem::Version
87
- version: 1.5.2
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: !ruby/object:Gem::Requirement
90
+ version_requirements: &id005 !ruby/object:Gem::Requirement
91
91
  none: false
92
- requirements:
93
- - - '='
94
- - !ruby/object:Gem::Version
92
+ requirements:
93
+ - - "="
94
+ - !ruby/object:Gem::Version
95
+ hash: 7
96
+ segments:
97
+ - 1
98
+ - 5
99
+ - 2
95
100
  version: 1.5.2
96
- - !ruby/object:Gem::Dependency
101
+ requirement: *id005
102
+ - !ruby/object:Gem::Dependency
97
103
  name: fakefs
98
- requirement: !ruby/object:Gem::Requirement
99
- none: false
100
- requirements:
101
- - - '='
102
- - !ruby/object:Gem::Version
103
- version: 0.4.0
104
104
  type: :development
105
105
  prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
106
+ version_requirements: &id006 !ruby/object:Gem::Requirement
107
107
  none: false
108
- requirements:
109
- - - '='
110
- - !ruby/object:Gem::Version
108
+ requirements:
109
+ - - "="
110
+ - !ruby/object:Gem::Version
111
+ hash: 15
112
+ segments:
113
+ - 0
114
+ - 4
115
+ - 0
111
116
  version: 0.4.0
112
- - !ruby/object:Gem::Dependency
117
+ requirement: *id006
118
+ - !ruby/object:Gem::Dependency
113
119
  name: syntax
114
- requirement: !ruby/object:Gem::Requirement
115
- none: false
116
- requirements:
117
- - - '='
118
- - !ruby/object:Gem::Version
119
- version: 1.0.0
120
120
  type: :development
121
121
  prerelease: false
122
- version_requirements: !ruby/object:Gem::Requirement
122
+ version_requirements: &id007 !ruby/object:Gem::Requirement
123
123
  none: false
124
- requirements:
125
- - - '='
126
- - !ruby/object:Gem::Version
124
+ requirements:
125
+ - - "="
126
+ - !ruby/object:Gem::Version
127
+ hash: 23
128
+ segments:
129
+ - 1
130
+ - 0
131
+ - 0
127
132
  version: 1.0.0
128
- - !ruby/object:Gem::Dependency
133
+ requirement: *id007
134
+ - !ruby/object:Gem::Dependency
129
135
  name: mocha
130
- requirement: !ruby/object:Gem::Requirement
131
- none: false
132
- requirements:
133
- - - ~>
134
- - !ruby/object:Gem::Version
135
- version: 0.10.5
136
136
  type: :development
137
137
  prerelease: false
138
- version_requirements: !ruby/object:Gem::Requirement
138
+ version_requirements: &id008 !ruby/object:Gem::Requirement
139
139
  none: false
140
- requirements:
140
+ requirements:
141
141
  - - ~>
142
- - !ruby/object:Gem::Version
142
+ - !ruby/object:Gem::Version
143
+ hash: 61
144
+ segments:
145
+ - 0
146
+ - 10
147
+ - 5
143
148
  version: 0.10.5
144
- - !ruby/object:Gem::Dependency
149
+ requirement: *id008
150
+ - !ruby/object:Gem::Dependency
145
151
  name: rr
146
- requirement: !ruby/object:Gem::Requirement
147
- none: false
148
- requirements:
149
- - - ~>
150
- - !ruby/object:Gem::Version
151
- version: 1.0.4
152
152
  type: :development
153
153
  prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
154
+ version_requirements: &id009 !ruby/object:Gem::Requirement
155
155
  none: false
156
- requirements:
156
+ requirements:
157
157
  - - ~>
158
- - !ruby/object:Gem::Version
158
+ - !ruby/object:Gem::Version
159
+ hash: 31
160
+ segments:
161
+ - 1
162
+ - 0
163
+ - 4
159
164
  version: 1.0.4
160
- - !ruby/object:Gem::Dependency
165
+ requirement: *id009
166
+ - !ruby/object:Gem::Dependency
161
167
  name: flexmock
162
- requirement: !ruby/object:Gem::Requirement
163
- none: false
164
- requirements:
165
- - - ~>
166
- - !ruby/object:Gem::Version
167
- version: 0.9.0
168
168
  type: :development
169
169
  prerelease: false
170
- version_requirements: !ruby/object:Gem::Requirement
170
+ version_requirements: &id010 !ruby/object:Gem::Requirement
171
171
  none: false
172
- requirements:
172
+ requirements:
173
173
  - - ~>
174
- - !ruby/object:Gem::Version
174
+ - !ruby/object:Gem::Version
175
+ hash: 59
176
+ segments:
177
+ - 0
178
+ - 9
179
+ - 0
175
180
  version: 0.9.0
181
+ requirement: *id010
176
182
  description: BDD for Ruby. RSpec runner and example groups.
177
183
  email: rspec-users@rubyforge.org
178
- executables:
184
+ executables:
179
185
  - autospec
180
186
  - rspec
181
187
  extensions: []
188
+
182
189
  extra_rdoc_files: []
183
- files:
190
+
191
+ files:
184
192
  - lib/autotest/discover.rb
185
193
  - lib/autotest/rspec2.rb
186
194
  - lib/rspec/autorun.rb
@@ -349,43 +357,42 @@ files:
349
357
  - spec/support/matchers.rb
350
358
  - spec/support/shared_example_groups.rb
351
359
  - spec/support/spec_files.rb
352
- - !binary |-
353
- ZXhlL2F1dG9zcGVj
354
- - !binary |-
355
- ZXhlL3JzcGVj
360
+ - exe/autospec
361
+ - exe/rspec
356
362
  homepage: http://github.com/rspec/rspec-core
357
- licenses:
363
+ licenses:
358
364
  - MIT
359
365
  post_install_message:
360
- rdoc_options:
366
+ rdoc_options:
361
367
  - --charset=UTF-8
362
- require_paths:
368
+ require_paths:
363
369
  - lib
364
- required_ruby_version: !ruby/object:Gem::Requirement
370
+ required_ruby_version: !ruby/object:Gem::Requirement
365
371
  none: false
366
- requirements:
367
- - - ! '>='
368
- - !ruby/object:Gem::Version
369
- version: '0'
370
- segments:
372
+ requirements:
373
+ - - ">="
374
+ - !ruby/object:Gem::Version
375
+ hash: 3
376
+ segments:
371
377
  - 0
372
- hash: 2822147403223549363
373
- required_rubygems_version: !ruby/object:Gem::Requirement
378
+ version: "0"
379
+ required_rubygems_version: !ruby/object:Gem::Requirement
374
380
  none: false
375
- requirements:
376
- - - ! '>='
377
- - !ruby/object:Gem::Version
378
- version: '0'
379
- segments:
381
+ requirements:
382
+ - - ">="
383
+ - !ruby/object:Gem::Version
384
+ hash: 3
385
+ segments:
380
386
  - 0
381
- hash: 2822147403223549363
387
+ version: "0"
382
388
  requirements: []
389
+
383
390
  rubyforge_project: rspec
384
- rubygems_version: 1.8.24
391
+ rubygems_version: 1.8.6
385
392
  signing_key:
386
393
  specification_version: 3
387
- summary: rspec-core-2.11.0
388
- test_files:
394
+ summary: rspec-core-2.11.1
395
+ test_files:
389
396
  - features/Autotest.md
390
397
  - features/README.md
391
398
  - features/Upgrade.md