rspec-mocks 3.1.2 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 392038fa8cfca9fe1c25e2285b52744941fe41d9
4
- data.tar.gz: 3287a586cb0ea0b1b658df9e5ec8174973a0f420
3
+ metadata.gz: 8967bb910d6e9e42450e14ac9ce3fd37b078ba5e
4
+ data.tar.gz: e05cfe6e3b29c252f091de7f562e3b2424a14a1c
5
5
  SHA512:
6
- metadata.gz: b41e95654ea7db54ca337f9a1f2854b62c22a994f738cd4cacb0da48b2eee29385e69b53f64dfb6206d55905ca64a0c4cc964ddad4455c0a64e8202d694822c7
7
- data.tar.gz: 35964167001dc473f49efc12569e2df467c28ac050cdc5e7c2abdf1c452bd82faa2cd5d0835ebc29dd93400dfc3ca94731170fd5d3c358dd4ab7022c031b6dd7
6
+ metadata.gz: 72a62c1548028c0517d412fdd5b62bd8047135a6a25696f180df864b9cc4e0332be07f29290888fe1375afa7de822e404f36d6111e83ab739dee57cbf5676c17
7
+ data.tar.gz: 496c5678781c6c5f14a3d929521f3e57698a28bf25766efd67eb5d918f93c108467228636275fbedbf71a34b56d28acb001ce47a6bd215cf74bb28e465b28b39
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,17 @@
1
+ ### 3.1.3 / 2014-10-08
2
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.1.2...v3.1.3)
3
+
4
+ Bug Fixes:
5
+
6
+ * Correct received messages count when used with `have_received` matcher.
7
+ (Jon Rowe, #793)
8
+ * Provide a clear error message when you use `allow_any_instance_of(...)` or
9
+ `expect_any_instance_of(...)` with the `have_received` matcher (they are
10
+ not intended to be used together and previously caused an odd internal
11
+ failure in rspec-mocks). (Jon Rowe, #799).
12
+ * Fix verified double `with` verification so that it applies to method
13
+ stubs. (Myron Marston, #790)
14
+
1
15
  ### 3.1.2 / 2014-09-26
2
16
  [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.1.1...v3.1.2)
3
17
 
data/README.md CHANGED
@@ -41,6 +41,9 @@ rspec-mocks supports 3 forms for declaring method stubs:
41
41
  ```ruby
42
42
  allow(book).to receive(:title) { "The RSpec Book" }
43
43
  allow(book).to receive(:title).and_return("The RSpec Book")
44
+ allow(book).to receive_messages(
45
+ :title => "The RSpec Book",
46
+ :subtitle => "Behaviour-Driven Development with RSpec, Cucumber, and Friends")
44
47
  ```
45
48
 
46
49
  You can also use this shortcut, which creates a test double and declares a
@@ -55,13 +55,25 @@ module RSpec
55
55
  end
56
56
 
57
57
  def setup_allowance(_subject, &_block)
58
- raise RSpec::Mocks::MockExpectationError,
59
- "Using allow(...) with the `have_received` matcher is not " \
60
- "supported as it would have no effect."
58
+ disallow("allow", " as it would have no effect")
59
+ end
60
+
61
+ def setup_any_instance_allowance(_subject, &_block)
62
+ disallow("allow_any_instance_of")
63
+ end
64
+
65
+ def setup_any_instance_expectation(_subject, &_block)
66
+ disallow("expect_any_instance_of")
61
67
  end
62
68
 
63
69
  private
64
70
 
71
+ def disallow(type, reason="")
72
+ raise RSpec::Mocks::MockExpectationError,
73
+ "Using #{type}(...) with the `have_received` " \
74
+ "matcher is not supported#{reason}."
75
+ end
76
+
65
77
  def expect
66
78
  @expectation ||= begin
67
79
  expectation = mock_proxy.build_expectation(@method_name)
@@ -228,14 +228,19 @@ module RSpec
228
228
  @message == message && @argument_list_matcher.args_match?(*args)
229
229
  end
230
230
 
231
+ # @private
232
+ def safe_invoke(parent_stub, *args, &block)
233
+ invoke_incrementing_actual_calls_by(1, false, parent_stub, *args, &block)
234
+ end
235
+
231
236
  # @private
232
237
  def invoke(parent_stub, *args, &block)
233
- invoke_incrementing_actual_calls_by(1, parent_stub, *args, &block)
238
+ invoke_incrementing_actual_calls_by(1, true, parent_stub, *args, &block)
234
239
  end
235
240
 
236
241
  # @private
237
242
  def invoke_without_incrementing_received_count(parent_stub, *args, &block)
238
- invoke_incrementing_actual_calls_by(0, parent_stub, *args, &block)
243
+ invoke_incrementing_actual_calls_by(0, true, parent_stub, *args, &block)
239
244
  end
240
245
 
241
246
  # @private
@@ -504,10 +509,10 @@ module RSpec
504
509
 
505
510
  private
506
511
 
507
- def invoke_incrementing_actual_calls_by(increment, parent_stub, *args, &block)
512
+ def invoke_incrementing_actual_calls_by(increment, allowed_to_fail, parent_stub, *args, &block)
508
513
  args.unshift(orig_object) if yield_receiver_to_implementation_block?
509
514
 
510
- if negative? || ((@exactly || @at_most) && (@actual_received_count == @expected_received_count))
515
+ if negative? || (allowed_to_fail && (@exactly || @at_most) && (@actual_received_count == @expected_received_count))
511
516
  @actual_received_count += increment
512
517
  @failed_fast = true
513
518
  # args are the args we actually received, @argument_list_matcher is the
@@ -91,7 +91,7 @@ module RSpec
91
91
  @messages_received.each do |(actual_method_name, args, _)|
92
92
  next unless expectation.matches?(actual_method_name, *args)
93
93
 
94
- expectation.invoke(nil)
94
+ expectation.safe_invoke(nil)
95
95
  block.call(*args) if block
96
96
  end
97
97
  end
@@ -121,6 +121,11 @@ module RSpec
121
121
  super(*args, &block).tap { |x| x.method_reference = @method_reference }
122
122
  end
123
123
 
124
+ def add_stub(*args, &block)
125
+ # explict params necessary for 1.8.7 see #626
126
+ super(*args, &block).tap { |x| x.method_reference = @method_reference }
127
+ end
128
+
124
129
  def proxy_method_invoked(obj, *args, &block)
125
130
  validate_arguments!(args)
126
131
  super
@@ -3,7 +3,7 @@ module RSpec
3
3
  # Version information for RSpec mocks.
4
4
  module Version
5
5
  # Version of RSpec mocks currently in use in SemVer format.
6
- STRING = '3.1.2'
6
+ STRING = '3.1.3'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-mocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Baker
@@ -33,7 +33,7 @@ cert_chain:
33
33
  1yHC1AcSYpvi2dAbOiHT5iQF+krm4wse8KctXgTNnjMsHEoGKulJS2/sZl90jcCz
34
34
  muA=
35
35
  -----END CERTIFICATE-----
36
- date: 2014-09-26 00:00:00.000000000 Z
36
+ date: 2014-10-09 00:00:00.000000000 Z
37
37
  dependencies:
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec-support
@@ -179,6 +179,6 @@ rubyforge_project: rspec
179
179
  rubygems_version: 2.2.2
180
180
  signing_key:
181
181
  specification_version: 4
182
- summary: rspec-mocks-3.1.2
182
+ summary: rspec-mocks-3.1.3
183
183
  test_files: []
184
184
  has_rdoc:
metadata.gz.sig CHANGED
Binary file