rspec-mocks 3.9.1 → 3.10.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
  SHA256:
3
- metadata.gz: a2e1e958a5a621513f9854bca7ac6fc45048e3ef493a78ed1a748bd8f4e87430
4
- data.tar.gz: 56c6a88292c8fb57b3fd4de0adbc8ce7c5cabc4ec22a3374e1c13aae846db988
3
+ metadata.gz: a4977129849498908e5c8b2ca7cf93d16884a08ab6dd5511558e80a17ca59343
4
+ data.tar.gz: e97a221ae0a1a0b79b809454095a0c0d4cef3048b4b17408d1c4f1e11efad075
5
5
  SHA512:
6
- metadata.gz: '098987b9f29a04beb11feb2a154fc8bb7b243e3a9db8fa163441118ac8eb04d48ce6e777b8c1046bc264f4aa1160a228379fd6eecf5f17abeaf574503a720991'
7
- data.tar.gz: 1f0c7da266382660d474e09ca064b0fc8252d5ed5be4c1b9569e3ee92767931a16e70ebc82f8784cb3c468c9c98b1674ca79f526fa179e9c06b6c29d481dd914
6
+ metadata.gz: 50d2119f48c3f066738682dec9ce64f7287204d620eb081bb6079b246e68219a0cf0dc3b9cfe0ca2681da097a8c6bbfc8827f55e29f2f584de741adb837814bd
7
+ data.tar.gz: 39a62e9a35234b6021eff74dad5cb535e3b56b64060e8ea342ac38d8cfb24764d4971e52b47fa6c6963fcd2f6463231683fe54af4119f1389a98e20b9215286b
checksums.yaml.gz.sig CHANGED
Binary file
data/Changelog.md CHANGED
@@ -1,3 +1,46 @@
1
+ ### Development
2
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.10.3...3-10-maintenance)
3
+
4
+ ### 3.10.3 / 2021-01-28
5
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.10.2...v3.10.3)
6
+
7
+ Bug Fixes:
8
+
9
+ * Suppress warning by setting `$VERBOSE` to nil. (Nobuyoshi Nakada, #1414)
10
+ * Support keyword argument semantics when constraining argument expectations using
11
+ `with` on Ruby 3.0+ (Yusuke Endoh, #1394)
12
+
13
+ ### 3.10.2 / 2021-01-27
14
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.10.1...v3.10.2)
15
+
16
+ Bug Fixes:
17
+
18
+ * Support keyword arguments with `and_call_original` on Ruby 3.0.
19
+ (Bryan Powell, #1385)
20
+ * `RSpec::Mocks::Constant#previously_defined?` is now always a boolean.
21
+ (Phil Pirozhkov, #1397)
22
+ * Support keyword arguments on Ruby 3.0 when used with `expect_any_instance_of`
23
+ or `allow_any_instance_of` with `and_call_original`.
24
+ (Jess Hottenstein, #1407)
25
+
26
+ ### 3.10.1 / 2020-12-27
27
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.10.0...v3.10.1)
28
+
29
+ Bug Fixes:
30
+
31
+ * Issue `ArgumentError` rather than `TypeError` when unsupported methods on
32
+ unsupported objects are attempted to be stubbed. (@zhisme, #1357)
33
+
34
+ ### 3.10.0 / 2020-10-30
35
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.9.1...v3.10.0)
36
+
37
+ Enhancements:
38
+ * Add the ability to set a custom error generator in `MessageExpectation`.
39
+ This will allow rspec-expectations to inject a custom failure message.
40
+ (Benoit Tigeot and Nicolas Zermati, #1312)
41
+ * Return the result of the block passed to `RSpec::Mocks.with_temporary_scope`
42
+ when block run. (@expeehaa, #1329)
43
+
1
44
  ### 3.9.1 / 2019-12-31
2
45
  [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.9.0...v3.9.1)
3
46
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # RSpec Mocks [![Build Status](https://secure.travis-ci.org/rspec/rspec-mocks.svg?branch=master)](http://travis-ci.org/rspec/rspec-mocks) [![Code Climate](https://codeclimate.com/github/rspec/rspec-mocks.svg)](https://codeclimate.com/github/rspec/rspec-mocks)
1
+ # RSpec Mocks [![Build Status](https://github.com/rspec/rspec-mocks/workflows/RSpec%20CI/badge.svg?branch=3-10-maintenance)](https://github.com/rspec/rspec-mocks/actions) [![Code Climate](https://codeclimate.com/github/rspec/rspec-mocks.svg)](https://codeclimate.com/github/rspec/rspec-mocks)
2
2
  rspec-mocks is a test-double framework for rspec with support for method stubs,
3
3
  fakes, and message expectations on generated test-doubles and real objects
4
4
  alike.
@@ -8,12 +8,12 @@ alike.
8
8
  gem install rspec # for rspec-core, rspec-expectations, rspec-mocks
9
9
  gem install rspec-mocks # for rspec-mocks only
10
10
 
11
- Want to run against the `master` branch? You'll need to include the dependent
11
+ Want to run against the `main` branch? You'll need to include the dependent
12
12
  RSpec repos as well. Add the following to your `Gemfile`:
13
13
 
14
14
  ```ruby
15
15
  %w[rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
16
- gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'master'
16
+ gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'main'
17
17
  end
18
18
  ```
19
19
  ## Contributing
@@ -53,7 +53,7 @@ book = instance_double("Book", :pages => 250)
53
53
  Verifying doubles have some clever tricks to enable you to both test in
54
54
  isolation without your dependencies loaded while still being able to validate
55
55
  them against real objects. More detail is available in [their
56
- documentation](https://github.com/rspec/rspec-mocks/blob/master/features/verifying_doubles).
56
+ documentation](https://github.com/rspec/rspec-mocks/blob/main/features/verifying_doubles).
57
57
 
58
58
  Verifying doubles can also accept custom identifiers, just like double(), e.g.:
59
59
 
@@ -403,7 +403,7 @@ your code.
403
403
  ## Stubbing and Hiding Constants
404
404
 
405
405
  See the [mutating constants
406
- README](https://github.com/rspec/rspec-mocks/blob/master/features/mutating_constants/README.md)
406
+ README](https://github.com/rspec/rspec-mocks/blob/main/features/mutating_constants/README.md)
407
407
  for info on this feature.
408
408
 
409
409
  ## Use `before(:example)`, not `before(:context)`
@@ -261,6 +261,7 @@ module RSpec
261
261
  recorder.playback!(self, method_name)
262
262
  __send__(method_name, *args, &blk)
263
263
  end
264
+ @klass.__send__(:ruby2_keywords, method_name) if @klass.respond_to?(:ruby2_keywords, true)
264
265
  end
265
266
 
266
267
  def mark_invoked!(method_name)
@@ -46,16 +46,30 @@ module RSpec
46
46
  @expected_args = expected_args
47
47
  ensure_expected_args_valid!
48
48
  end
49
+ ruby2_keywords :initialize if Module.private_method_defined?(:ruby2_keywords)
49
50
 
50
51
  # @api public
51
- # @param [Array] args
52
+ # @param [Array] actual_args
52
53
  #
53
54
  # Matches each element in the `expected_args` against the element in the same
54
55
  # position of the arguments passed to `new`.
55
56
  #
56
57
  # @see #initialize
57
- def args_match?(*args)
58
- Support::FuzzyMatcher.values_match?(resolve_expected_args_based_on(args), args)
58
+ def args_match?(*actual_args)
59
+ expected_args = resolve_expected_args_based_on(actual_args)
60
+
61
+ return false if expected_args.size != actual_args.size
62
+
63
+ if RUBY_VERSION >= "3"
64
+ # if both arguments end with Hashes, and if one is a keyword hash and the other is not, they don't match
65
+ if Hash === expected_args.last && Hash === actual_args.last
66
+ if !Hash.ruby2_keywords_hash?(actual_args.last) && Hash.ruby2_keywords_hash?(expected_args.last)
67
+ return false
68
+ end
69
+ end
70
+ end
71
+
72
+ Support::FuzzyMatcher.values_match?(expected_args, actual_args)
59
73
  end
60
74
 
61
75
  # @private
@@ -62,6 +62,7 @@ module RSpec
62
62
  @recorded_customizations << ExpectationCustomization.new(method, args, block)
63
63
  self
64
64
  end
65
+ ruby2_keywords(method) if Module.private_method_defined?(:ruby2_keywords)
65
66
  end
66
67
 
67
68
  private
@@ -53,7 +53,7 @@ module RSpec
53
53
  # etc.
54
54
  #
55
55
  # If the message is received more times than there are values, the last
56
- # value is received for every subsequent call.
56
+ # value is returned for every subsequent call.
57
57
  #
58
58
  # @return [nil] No further chaining is supported after this.
59
59
  # @example
@@ -322,6 +322,7 @@ module RSpec
322
322
  @argument_list_matcher = ArgumentListMatcher.new(*args)
323
323
  self
324
324
  end
325
+ ruby2_keywords(:with) if Module.private_method_defined?(:ruby2_keywords)
325
326
 
326
327
  # Expect messages to be received in a specific order.
327
328
  #
@@ -366,7 +367,7 @@ module RSpec
366
367
  attr_reader :message
367
368
  attr_reader :orig_object
368
369
  attr_writer :expected_received_count, :expected_from, :argument_list_matcher
369
- protected :expected_received_count=, :expected_from=, :error_generator, :error_generator=, :implementation=
370
+ protected :expected_received_count=, :expected_from=, :error_generator=, :implementation=
370
371
 
371
372
  # @private
372
373
  attr_reader :type
@@ -376,7 +377,7 @@ module RSpec
376
377
  type=:expectation, opts={}, &implementation_block)
377
378
  @type = type
378
379
  @error_generator = error_generator
379
- @error_generator.opts = opts
380
+ @error_generator.opts = error_generator.opts.merge(opts)
380
381
  @expected_from = expected_from
381
382
  @method_double = method_double
382
383
  @orig_object = @method_double.object
@@ -63,6 +63,7 @@ module RSpec
63
63
  define_method(method_name) do |*args, &block|
64
64
  method_double.proxy_method_invoked(self, *args, &block)
65
65
  end
66
+ ruby2_keywords(method_name) if Module.private_method_defined?(:ruby2_keywords)
66
67
  __send__(visibility, method_name)
67
68
  end
68
69
 
@@ -66,7 +66,7 @@ module RSpec
66
66
 
67
67
  # @private
68
68
  def self.unmutated(name)
69
- previously_defined = recursive_const_defined?(name)
69
+ previously_defined = !!recursive_const_defined?(name)
70
70
  rescue NameError
71
71
  new(name) do |c|
72
72
  c.valid_name = false
@@ -21,6 +21,8 @@ module RSpec
21
21
 
22
22
  # @private
23
23
  def initialize(object, order_group, options={})
24
+ ensure_can_be_proxied!(object)
25
+
24
26
  @object = object
25
27
  @order_group = order_group
26
28
  @error_generator = ErrorGenerator.new(object)
@@ -31,6 +33,20 @@ module RSpec
31
33
  @method_doubles = Hash.new { |h, k| h[k] = MethodDouble.new(@object, k, self) }
32
34
  end
33
35
 
36
+ # @private
37
+ def ensure_can_be_proxied!(object)
38
+ return unless object.is_a?(Symbol) || object.frozen?
39
+ return if object.nil?
40
+
41
+ msg = "Cannot proxy frozen objects"
42
+ if Symbol === object
43
+ msg << ". Symbols such as #{object} cannot be mocked or stubbed."
44
+ else
45
+ msg << ", rspec-mocks relies on proxies for method stubbing and expectations."
46
+ end
47
+ raise ArgumentError, msg
48
+ end
49
+
34
50
  # @private
35
51
  attr_reader :object
36
52
 
@@ -34,23 +34,15 @@ module RSpec
34
34
  super
35
35
  end
36
36
 
37
- # @private
38
- module SilentIO
39
- def self.method_missing(*); end
40
- def self.respond_to?(*)
41
- true
42
- end
43
- end
44
-
45
37
  # Redefining `__send__` causes ruby to issue a warning.
46
- old, $stderr = $stderr, SilentIO
38
+ old, $VERBOSE = $VERBOSE, nil
47
39
  def __send__(name, *args, &block)
48
40
  @__sending_message = name
49
41
  super
50
42
  ensure
51
43
  @__sending_message = nil
52
44
  end
53
- $stderr = old
45
+ $VERBOSE = old
54
46
 
55
47
  def send(name, *args, &block)
56
48
  __send__(name, *args, &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.9.1'
6
+ STRING = '3.10.3'
7
7
  end
8
8
  end
9
9
  end
data/lib/rspec/mocks.rb CHANGED
@@ -87,12 +87,15 @@ module RSpec
87
87
 
88
88
  # Call the passed block and verify mocks after it has executed. This allows
89
89
  # mock usage in arbitrary places, such as a `before(:all)` hook.
90
+ #
91
+ # @return [Object] the return value from the block
90
92
  def self.with_temporary_scope
91
93
  setup
92
94
 
93
95
  begin
94
- yield
96
+ result = yield
95
97
  verify
98
+ result
96
99
  ensure
97
100
  teardown
98
101
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-mocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.1
4
+ version: 3.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Baker
8
8
  - David Chelimsky
9
9
  - Myron Marston
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain:
13
13
  - |
@@ -45,7 +45,7 @@ cert_chain:
45
45
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
46
46
  F3MdtaDehhjC
47
47
  -----END CERTIFICATE-----
48
- date: 2019-12-31 00:00:00.000000000 Z
48
+ date: 2022-01-28 00:00:00.000000000 Z
49
49
  dependencies:
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rspec-support
@@ -53,14 +53,14 @@ dependencies:
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 3.9.0
56
+ version: 3.10.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.9.0
63
+ version: 3.10.0
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: diff-lcs
66
66
  requirement: !ruby/object:Gem::Requirement
@@ -85,30 +85,30 @@ dependencies:
85
85
  name: rake
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
88
+ - - ">"
89
89
  - !ruby/object:Gem::Version
90
90
  version: 10.0.0
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - "~>"
95
+ - - ">"
96
96
  - !ruby/object:Gem::Version
97
97
  version: 10.0.0
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: cucumber
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - "~>"
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
- version: 1.3.15
104
+ version: '1.3'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - "~>"
109
+ - - ">="
110
110
  - !ruby/object:Gem::Version
111
- version: 1.3.15
111
+ version: '1.3'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: aruba
114
114
  requirement: !ruby/object:Gem::Requirement
@@ -194,11 +194,11 @@ licenses:
194
194
  - MIT
195
195
  metadata:
196
196
  bug_tracker_uri: https://github.com/rspec/rspec-mocks/issues
197
- changelog_uri: https://github.com/rspec/rspec-mocks/blob/v3.9.1/Changelog.md
197
+ changelog_uri: https://github.com/rspec/rspec-mocks/blob/v3.10.3/Changelog.md
198
198
  documentation_uri: https://rspec.info/documentation/
199
199
  mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
200
200
  source_code_uri: https://github.com/rspec/rspec-mocks
201
- post_install_message:
201
+ post_install_message:
202
202
  rdoc_options:
203
203
  - "--charset=UTF-8"
204
204
  require_paths:
@@ -214,8 +214,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
216
  requirements: []
217
- rubygems_version: 3.1.1
218
- signing_key:
217
+ rubygems_version: 3.3.3
218
+ signing_key:
219
219
  specification_version: 4
220
- summary: rspec-mocks-3.9.1
220
+ summary: rspec-mocks-3.10.3
221
221
  test_files: []
metadata.gz.sig CHANGED
Binary file