rspec-mocks 3.6.0.beta2 → 3.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6c37eb5169117ac444e7a9d41ab4f5b15dad89b
4
- data.tar.gz: 497665104d3a18cc63b7885ff5245aef032adcdb
3
+ metadata.gz: 0194543e201f9d8cb6c477dcdeaf678b3f5ce442
4
+ data.tar.gz: bd1e7cae196ec0d61c4dd714c4371b27e3d8c9f1
5
5
  SHA512:
6
- metadata.gz: 305e32ea97e0a65321396c04656441e7691b426e0189897ac4f93e21f85f5e39b670b3d7bc056d7a23e19c12f0cac5d6a9f0e0dfaca163ce8e769e57b1ca2255
7
- data.tar.gz: ae7fd2b5cf7cade09e6b1228af2da53a9249d060acd8e3160eb1b448d8516bb3cb84250e5a216cbce1f4d207dbc02561cef09f6188a4f6d9d37c281e38e82b61
6
+ metadata.gz: 13bfadb0ccb5f89efaa761ab93de080a4d9da94568965e55b03c53e104fb57ec283311e4395ecdb497fcff11f648b6649daaf117b1e486eced3040b1b8b04268
7
+ data.tar.gz: 627998b4615c8de8e236ac46788da589e9f16acbcfe75d310af7119dff3ee69a0e1eb2981b9947e2b102d546a0c5b2fd06780fc191fb3b2362b102dbb16dc400
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,15 @@
1
+ ### 3.6.0 / 2017-05-04
2
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.6.0.beta2...v3.6.0)
3
+
4
+ Bug Fixes:
5
+
6
+ * Fix "instance variable @color not initialized" warning when using
7
+ rspec-mocks without rspec-core. (Myron Marston, #1142)
8
+ * Restore aliased module methods properly when stubbing on 1.8.7.
9
+ (Samuel Giddins, #1144)
10
+ * Allow a message chain expectation to be constrained by argument(s).
11
+ (Jon Rowe, #1156)
12
+
1
13
  ### 3.6.0.beta2 / 2016-12-12
2
14
  [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.6.0.beta1...v3.6.0.beta2)
3
15
 
data/README.md CHANGED
@@ -101,6 +101,21 @@ that iterates through them:
101
101
  order.calculate_total_price(double(:price => 1.99), double(:price => 2.99))
102
102
  ```
103
103
 
104
+ ### Stubbing a chain of methods
105
+
106
+ You can use `receive_message_chain` in place of `receive` to stub a chain of messages:
107
+
108
+ ```ruby
109
+ allow(double).to receive_message_chain("foo.bar") { :baz }
110
+ allow(double).to receive_message_chain(:foo, :bar => :baz)
111
+ allow(double).to receive_message_chain(:foo, :bar) { :baz }
112
+
113
+ # Given any of the above forms:
114
+ double.foo.bar # => :baz
115
+ ```
116
+
117
+ Chains can be arbitrarily long, which makes it quite painless to violate the Law of Demeter in violent ways, so you should consider any use of `receive_message_chain` a code smell. Even though not all code smells indicate real problems (think fluent interfaces), `receive_message_chain` still results in brittle examples. For example, if you write `allow(foo).to receive_message_chain(:bar, :baz => 37)` in a spec and then the implementation calls `foo.baz.bar`, the stub will not work.
118
+
104
119
  ## Consecutive return values
105
120
 
106
121
  When a stub might be invoked more than once, you can provide additional
@@ -23,11 +23,7 @@ module RSpec
23
23
  end
24
24
 
25
25
  def invocation_order
26
- @invocation_order ||= {
27
- :and_return => [nil],
28
- :and_raise => [nil],
29
- :and_yield => [nil]
30
- }
26
+ EmptyInvocationOrder
31
27
  end
32
28
  end
33
29
  end
@@ -35,12 +35,14 @@ module RSpec
35
35
  me
36
36
  end
37
37
 
38
- def invocation_order
39
- @invocation_order ||= {
40
- :with => [nil],
38
+ ExpectationInvocationOrder =
39
+ {
41
40
  :and_return => [:with, nil],
42
- :and_raise => [:with, nil]
43
- }
41
+ :and_raise => [:with, nil],
42
+ }.freeze
43
+
44
+ def invocation_order
45
+ ExpectationInvocationOrder
44
46
  end
45
47
  end
46
48
  end
@@ -25,20 +25,24 @@ module RSpec
25
25
  stub
26
26
  end
27
27
 
28
- def invocation_order
29
- @invocation_order ||= {
30
- :with => [nil],
28
+ InovcationOrder =
29
+ {
31
30
  :and_return => [:with, nil],
32
31
  :and_raise => [:with, nil],
33
32
  :and_yield => [:with, :and_yield, nil],
34
33
  :and_throw => [:with, nil],
35
34
  :and_call_original => [:with, nil],
36
35
  :and_wrap_original => [:with, nil]
37
- }
36
+ }.freeze
37
+
38
+ EmptyInvocationOrder = {}.freeze
39
+
40
+ def invocation_order
41
+ InovcationOrder
38
42
  end
39
43
 
40
44
  def verify_invocation_order(rspec_method_name, *_args, &_block)
41
- return if invocation_order[rspec_method_name].include?(last_message)
45
+ return if invocation_order.fetch(rspec_method_name, [nil]).include?(last_message)
42
46
  raise NoMethodError, "Undefined method #{rspec_method_name}"
43
47
  end
44
48
  end
@@ -15,12 +15,7 @@ module RSpec
15
15
  end
16
16
 
17
17
  def invocation_order
18
- @invocation_order ||= {
19
- :with => [nil],
20
- :and_return => [nil],
21
- :and_raise => [nil],
22
- :and_yield => [nil]
23
- }
18
+ EmptyInvocationOrder
24
19
  end
25
20
  end
26
21
  end
@@ -9,6 +9,7 @@ module RSpec
9
9
  @transfer_nested_constants = false
10
10
  @verify_partial_doubles = false
11
11
  @temporarily_suppress_partial_double_verification = false
12
+ @color = false
12
13
  end
13
14
 
14
15
  # Sets whether RSpec will warn, ignore, or fail a test when
@@ -214,8 +214,8 @@ module RSpec
214
214
 
215
215
  def expectation_on_nil_message(method_name)
216
216
  "An expectation of `:#{method_name}` was set on `nil`. " \
217
- "To allow expectations on `nil` and suppress this message, set `config.allow_message_expectations_on_nil` to `true`. " \
218
- "To disallow expectations on `nil`, set `config.allow_message_expectations_on_nil` to `false`"
217
+ "To allow expectations on `nil` and suppress this message, set `RSpec::Mocks.configuration.allow_message_expectations_on_nil` to `true`. " \
218
+ "To disallow expectations on `nil`, set `RSpec::Mocks.configuration.allow_message_expectations_on_nil` to `false`"
219
219
  end
220
220
 
221
221
  # @private
@@ -392,7 +392,7 @@ module RSpec
392
392
  def self.included(klass)
393
393
  klass.class_exec do
394
394
  # This gets mixed in so that if `RSpec::Matchers` is included in
395
- # `klass` later, it's definition of `expect` will take precedence.
395
+ # `klass` later, its definition of `expect` will take precedence.
396
396
  include ExpectHost unless method_defined?(:expect)
397
397
  end
398
398
  end
@@ -400,7 +400,7 @@ module RSpec
400
400
  # @private
401
401
  def self.extended(object)
402
402
  # This gets extended in so that if `RSpec::Matchers` is included in
403
- # `klass` later, it's definition of `expect` will take precedence.
403
+ # `klass` later, its definition of `expect` will take precedence.
404
404
  object.extend ExpectHost unless object.respond_to?(:expect)
405
405
  end
406
406
 
@@ -128,6 +128,17 @@ module RSpec
128
128
  # Hence, we verify that the owner actually has the method defined.
129
129
  # If the given owner does not have the method defined, we assume
130
130
  # that the method is actually owned by @klass.
131
+ #
132
+ # On 1.8, aliased methods can also report the wrong owner. Example:
133
+ # module M
134
+ # def a; end
135
+ # module_function :a
136
+ # alias b a
137
+ # module_function :b
138
+ # end
139
+ # The owner of M.b is the raw Module object, instead of the expected
140
+ # singleton class of the module
141
+ return true if RUBY_VERSION < '1.9' && owner == @object
131
142
  owner == @klass || !(method_defined_on_klass?(owner))
132
143
  end
133
144
  end
@@ -207,8 +207,8 @@ module RSpec
207
207
 
208
208
  # In Ruby 2.0.0 and above prepend will alter the method lookup chain.
209
209
  # We use an object's singleton class to define method doubles upon,
210
- # however if the object has had it's singleton class (as opposed to
211
- # it's actual class) prepended too then the the method lookup chain
210
+ # however if the object has had its singleton class (as opposed to
211
+ # its actual class) prepended too then the the method lookup chain
212
212
  # will look in the prepended module first, **before** the singleton
213
213
  # class.
214
214
  #
@@ -105,6 +105,10 @@ module RSpec
105
105
  # so you can stub constants in other contexts (e.g. helper
106
106
  # classes).
107
107
  def self.stub(constant_name, value, options={})
108
+ unless String === constant_name
109
+ raise ArgumentError, "`stub_const` requires a String, but you provided a #{constant_name.class.name}"
110
+ end
111
+
108
112
  mutator = if recursive_const_defined?(constant_name, &raise_on_invalid_const)
109
113
  DefinedConstantReplacer
110
114
  else
@@ -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.6.0.beta2'
6
+ STRING = '3.6.0'
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.6.0.beta2
4
+ version: 3.6.0
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-12-12 00:00:00.000000000 Z
48
+ date: 2017-05-04 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.6.0.beta2
56
+ version: 3.6.0
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.6.0.beta2
63
+ version: 3.6.0
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: diff-lcs
66
66
  requirement: !ruby/object:Gem::Requirement
@@ -205,14 +205,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
205
  version: 1.8.7
206
206
  required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  requirements:
208
- - - ">"
208
+ - - ">="
209
209
  - !ruby/object:Gem::Version
210
- version: 1.3.1
210
+ version: '0'
211
211
  requirements: []
212
212
  rubyforge_project:
213
- rubygems_version: 2.5.1
213
+ rubygems_version: 2.4.5.2
214
214
  signing_key:
215
215
  specification_version: 4
216
- summary: rspec-mocks-3.6.0.beta2
216
+ summary: rspec-mocks-3.6.0
217
217
  test_files: []
218
218
  has_rdoc:
metadata.gz.sig CHANGED
Binary file