rspec-mocks 3.4.1 → 3.5.0.beta1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5ce50f9bdd93d8059872838e7c1e042cd456633
4
- data.tar.gz: 2d50dc301a35c6f6ed05593c3da8461c987e3e7d
3
+ metadata.gz: f5342aa85d00e6bcc24d8debc05333f12d40b7ad
4
+ data.tar.gz: e4082539be10ac57f42759854b84d9bc8c4c15d8
5
5
  SHA512:
6
- metadata.gz: 9db8f83c7c1422db6ec35b2a8503ffa44ff0f78892f9ea0b48ff75aed54ed0637965b25d421df0839c8f29ce54d15d45b6e56e6172dff6a66a0e65721891f755
7
- data.tar.gz: 4fea4235e7df0352398356da94dbf6dedfc8abd6aa7db284ebb41cbdb7881067b8d2155ac7a3ccba5a5e5b47019e8c1450a0eab03f7538906b4c2bee2458dc72
6
+ metadata.gz: e5afda5c6811e7b3db5bb83b4957c5864d74a45fcc16fb9e84a8378d5dfb05c8eede815317fc6a6bbeb0cc378552d81837e7ed7e0c12a30b8838b512a8d9eef9
7
+ data.tar.gz: 177e8c07f662fa0a7b3a115218c50836aa5afe1da19c2bf679ab833dbe9041b048eac179b463cf9a8de385039f13a5133c7bf44a779fb2ad4329419b17745d24
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,18 @@
1
+ ### Development
2
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.5.0.beta1...master)
3
+
4
+ ### 3.5.0.beta1 / 2016-02-06
5
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.4.1...v3.5.0.beta1)
6
+
7
+ Bug Fixes:
8
+
9
+ * Allow `any_instance_of(...).to receive(...)` to use `and_yield` multiple
10
+ times. (Kilian Cirera Sant, #1054)
11
+ * Allow matchers which inherit from `rspec-mocks` matchers to be used for
12
+ `allow`. (Andrew Kozin, #1056)
13
+ * Prevent stubbing `respond_to?` on partial doubles from causing infinite
14
+ recursion. (Jon Rowe, #1013)
15
+
1
16
  ### 3.4.1 / 2016-01-10
2
17
  [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.4.0...v3.4.1)
3
18
 
@@ -117,6 +117,10 @@ module RSpec
117
117
 
118
118
  # Namespace for mock-related matchers.
119
119
  module Matchers
120
+ # @private
121
+ # just a "tag" for rspec-mock matchers detection
122
+ module Matcher; end
123
+
120
124
  autoload :HaveReceived, "rspec/mocks/matchers/have_received"
121
125
  autoload :Receive, "rspec/mocks/matchers/receive"
122
126
  autoload :ReceiveMessageChain, "rspec/mocks/matchers/receive_message_chain"
@@ -193,7 +193,28 @@ module RSpec
193
193
  alias_method_name = build_alias_method_name(method_name)
194
194
  @klass.class_exec(@backed_up_method_owner) do |backed_up_method_owner|
195
195
  remove_method method_name
196
- alias_method method_name, alias_method_name if backed_up_method_owner[method_name.to_sym] == self
196
+
197
+ # A @klass can have methods implemented (see Method#owner) in @klass
198
+ # or inherited from a superclass. In ruby 2.2 and earlier, we can copy
199
+ # a method regardless of the 'owner' and restore it to @klass after
200
+ # because a call to 'super' from @klass's copied method would end up
201
+ # calling the original class's superclass's method.
202
+ #
203
+ # With the commit below, available starting in 2.3.0, ruby changed
204
+ # this behavior and a call to 'super' from the method copied to @klass
205
+ # will call @klass's superclass method, which is the original
206
+ # implementer of this method! This leads to very strange errors
207
+ # if @klass's copied method calls 'super', since it would end up
208
+ # calling itself, the original method implemented in @klass's
209
+ # superclass.
210
+ #
211
+ # For ruby 2.3 and above, we need to only restore methods that
212
+ # @klass originally owned.
213
+ #
214
+ # https://github.com/ruby/ruby/commit/c8854d2ca4be9ee6946e6d17b0e17d9ef130ee81
215
+ if RUBY_VERSION < "2.3" || backed_up_method_owner[method_name.to_sym] == self
216
+ alias_method method_name, alias_method_name
217
+ end
197
218
  remove_method alias_method_name
198
219
  end
199
220
  end
@@ -30,7 +30,7 @@ module RSpec
30
30
  :with => [nil],
31
31
  :and_return => [:with, nil],
32
32
  :and_raise => [:with, nil],
33
- :and_yield => [:with, nil],
33
+ :and_yield => [:with, :and_yield, nil],
34
34
  :and_call_original => [:with, nil],
35
35
  :and_wrap_original => [:with, nil]
36
36
  }
@@ -3,6 +3,8 @@ module RSpec
3
3
  module Matchers
4
4
  # @private
5
5
  class HaveReceived
6
+ include Matcher
7
+
6
8
  COUNT_CONSTRAINTS = %w[exactly at_least at_most times once twice thrice]
7
9
  ARGS_CONSTRAINTS = %w[with]
8
10
  CONSTRAINTS = COUNT_CONSTRAINTS + ARGS_CONSTRAINTS + %w[ordered]
@@ -5,6 +5,8 @@ module RSpec
5
5
  module Matchers
6
6
  # @private
7
7
  class Receive
8
+ include Matcher
9
+
8
10
  def initialize(message, block)
9
11
  @message = message
10
12
  @block = block
@@ -5,6 +5,8 @@ module RSpec
5
5
  module Matchers
6
6
  # @private
7
7
  class ReceiveMessageChain
8
+ include Matcher
9
+
8
10
  def initialize(chain, &block)
9
11
  @chain = chain
10
12
  @block = block
@@ -3,6 +3,8 @@ module RSpec
3
3
  module Matchers
4
4
  # @private
5
5
  class ReceiveMessages
6
+ include Matcher
7
+
6
8
  def initialize(message_return_value_hash)
7
9
  @message_return_value_hash = message_return_value_hash
8
10
  @backtrace_line = CallerFilter.first_non_rspec_line
@@ -85,17 +85,25 @@ module RSpec
85
85
  end
86
86
 
87
87
  def self.method_visibility_for(object, method_name)
88
- instance_method_visibility_for(class << object; self; end, method_name).tap do |vis|
89
- # If the method is not defined on the class, `instance_method_visibility_for`
90
- # returns `nil`. However, it may be handled dynamically by `method_missing`,
91
- # so here we check `respond_to` (passing false to not check private methods).
92
- #
93
- # This only considers the public case, but I don't think it's possible to
94
- # write `method_missing` in such a way that it handles a dynamic message
95
- # with private or protected visibility. Ruby doesn't provide you with
96
- # the caller info.
97
- return :public if vis.nil? && object.respond_to?(method_name, false)
98
- end
88
+ vis = instance_method_visibility_for(class << object; self; end, method_name)
89
+
90
+ # If the method is not defined on the class, `instance_method_visibility_for`
91
+ # returns `nil`. However, it may be handled dynamically by `method_missing`,
92
+ # so here we check `respond_to` (passing false to not check private methods).
93
+ #
94
+ # This only considers the public case, but I don't think it's possible to
95
+ # write `method_missing` in such a way that it handles a dynamic message
96
+ # with private or protected visibility. Ruby doesn't provide you with
97
+ # the caller info.
98
+ return vis unless vis.nil?
99
+
100
+ proxy = RSpec::Mocks.space.proxy_for(object)
101
+ respond_to = proxy.method_double_if_exists_for_message(:respond_to?)
102
+
103
+ visible = respond_to && respond_to.original_method.call(method_name) ||
104
+ object.respond_to?(method_name)
105
+
106
+ return :public if visible
99
107
  end
100
108
  end
101
109
 
@@ -228,6 +228,11 @@ module RSpec
228
228
  end
229
229
  end
230
230
 
231
+ # @private
232
+ def method_double_if_exists_for_message(message)
233
+ method_double_for(message) if @method_doubles.key?(message.to_sym)
234
+ end
235
+
231
236
  private
232
237
 
233
238
  def method_double_for(message)
@@ -38,7 +38,7 @@ module RSpec
38
38
  private
39
39
 
40
40
  def matcher_allowed?(matcher)
41
- matcher.class.name.start_with?("RSpec::Mocks::Matchers".freeze)
41
+ Matchers::Matcher === matcher
42
42
  end
43
43
 
44
44
  def define_matcher(matcher, name, &block)
@@ -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.4.1'
6
+ STRING = '3.5.0.beta1'
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.4.1
4
+ version: 3.5.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Baker
@@ -45,22 +45,22 @@ cert_chain:
45
45
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
46
46
  F3MdtaDehhjC
47
47
  -----END CERTIFICATE-----
48
- date: 2016-01-10 00:00:00.000000000 Z
48
+ date: 2016-02-06 00:00:00.000000000 Z
49
49
  dependencies:
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rspec-support
52
52
  requirement: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - "~>"
54
+ - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: 3.4.0
56
+ version: 3.5.0.beta1
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - "~>"
61
+ - - '='
62
62
  - !ruby/object:Gem::Version
63
- version: 3.4.0
63
+ version: 3.5.0.beta1
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: diff-lcs
66
66
  requirement: !ruby/object:Gem::Requirement
@@ -204,14 +204,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
204
204
  version: 1.8.7
205
205
  required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - ">="
207
+ - - ">"
208
208
  - !ruby/object:Gem::Version
209
- version: '0'
209
+ version: 1.3.1
210
210
  requirements: []
211
211
  rubyforge_project:
212
- rubygems_version: 2.2.2
212
+ rubygems_version: 2.4.5.1
213
213
  signing_key:
214
214
  specification_version: 4
215
- summary: rspec-mocks-3.4.1
215
+ summary: rspec-mocks-3.5.0.beta1
216
216
  test_files: []
217
217
  has_rdoc:
metadata.gz.sig CHANGED
Binary file