rspec-mocks 3.5.0.beta2 → 3.5.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +4 -0
- data/lib/rspec/mocks/message_expectation.rb +11 -0
- data/lib/rspec/mocks/minitest_integration.rb +68 -0
- data/lib/rspec/mocks/targets.rb +48 -21
- data/lib/rspec/mocks/version.rb +1 -1
- metadata +8 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 120ba58f79094ffbb0cbc266d92aaf95e85dfb3e
|
4
|
+
data.tar.gz: b0550ddbdf1d1d12b5c2ced552eeed6e8dd9fe4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdec40e14778746cfa34d4625da45725560c2305ea3ffd993dbd9b2893c37b94b973d6343130ddd469661725b385b96deb0761e3cfc401207f6dbd8de9b2f708
|
7
|
+
data.tar.gz: 5bc6782dc04230c63393fad9c0d0a4fbb3d8fddaaee1d05ce08ffbc0ed24378a7725a12d6226b04393fd9b81b29bddfc29e07582c80ecd8340cc39417db42293
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -5,6 +5,10 @@ Enhancements:
|
|
5
5
|
|
6
6
|
* Improve error message displayed when using `and_wrap_original` on pure test
|
7
7
|
doubles. (betesh, #1063)
|
8
|
+
* Issue warning when attempting to use unsupported
|
9
|
+
`allow(...).to receive(...).ordered`. (Jon Rowe, #1000)
|
10
|
+
* Add `rspec/mocks/minitest_integration`, to properly integration rspec-mocks
|
11
|
+
with minitest. (Myron Marston, #1065)
|
8
12
|
|
9
13
|
Bug Fixes:
|
10
14
|
|
@@ -328,6 +328,13 @@ module RSpec
|
|
328
328
|
# expect(api).to receive(:run).ordered
|
329
329
|
# expect(api).to receive(:finish).ordered
|
330
330
|
def ordered(&block)
|
331
|
+
if type == :stub
|
332
|
+
RSpec.warning(
|
333
|
+
"`allow(...).to receive(..).ordered` is not supported and will" \
|
334
|
+
"have no effect, use `and_return(*ordered_values)` instead."
|
335
|
+
)
|
336
|
+
end
|
337
|
+
|
331
338
|
self.inner_implementation_action = block
|
332
339
|
additional_expected_calls.times do
|
333
340
|
@order_group.register(self)
|
@@ -349,9 +356,13 @@ module RSpec
|
|
349
356
|
attr_writer :expected_received_count, :expected_from, :argument_list_matcher
|
350
357
|
protected :expected_received_count=, :expected_from=, :error_generator, :error_generator=, :implementation=
|
351
358
|
|
359
|
+
# @private
|
360
|
+
attr_reader :type
|
361
|
+
|
352
362
|
# rubocop:disable Style/ParameterLists
|
353
363
|
def initialize(error_generator, expectation_ordering, expected_from, method_double,
|
354
364
|
type=:expectation, opts={}, &implementation_block)
|
365
|
+
@type = type
|
355
366
|
@error_generator = error_generator
|
356
367
|
@error_generator.opts = opts
|
357
368
|
@expected_from = expected_from
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'rspec/mocks'
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Mocks
|
5
|
+
# @private
|
6
|
+
module MinitestIntegration
|
7
|
+
include ::RSpec::Mocks::ExampleMethods
|
8
|
+
|
9
|
+
def before_setup
|
10
|
+
::RSpec::Mocks.setup
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def after_teardown
|
15
|
+
super
|
16
|
+
|
17
|
+
# Only verify if there's not already an error. Otherwise
|
18
|
+
# we risk getting the same failure twice, since negative
|
19
|
+
# expectation violations raise both when the message is
|
20
|
+
# unexpectedly received, and also during `verify` (in case
|
21
|
+
# the first failure was caught by user code via a
|
22
|
+
# `rescue Exception`).
|
23
|
+
::RSpec::Mocks.verify unless failures.any?
|
24
|
+
ensure
|
25
|
+
::RSpec::Mocks.teardown
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Minitest::Test.send(:include, RSpec::Mocks::MinitestIntegration)
|
32
|
+
|
33
|
+
if defined?(::Minitest::Expectation)
|
34
|
+
if defined?(::RSpec::Expectations) && ::Minitest::Expectation.method_defined?(:to)
|
35
|
+
# rspec/expectations/minitest_integration has already been loaded and
|
36
|
+
# has defined `to`/`not_to`/`to_not` on `Minitest::Expectation` so we do
|
37
|
+
# not want to here (or else we would interfere with rspec-expectations' definition).
|
38
|
+
else
|
39
|
+
# ...otherwise, define those methods now. If `rspec/expectations/minitest_integration`
|
40
|
+
# is loaded after this file, it'll overide the defintion here.
|
41
|
+
Minitest::Expectation.class_eval do
|
42
|
+
include RSpec::Mocks::ExpectationTargetMethods
|
43
|
+
|
44
|
+
def to(*args)
|
45
|
+
ctx.assertions += 1
|
46
|
+
super
|
47
|
+
end
|
48
|
+
|
49
|
+
def not_to(*args)
|
50
|
+
ctx.assertions += 1
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_not(*args)
|
55
|
+
ctx.assertions += 1
|
56
|
+
super
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
module RSpec
|
63
|
+
module Mocks
|
64
|
+
remove_const :MockExpectationError
|
65
|
+
# Raised when a message expectation is not satisfied.
|
66
|
+
MockExpectationError = ::Minitest::Assertion
|
67
|
+
end
|
68
|
+
end
|
data/lib/rspec/mocks/targets.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Mocks
|
3
3
|
# @private
|
4
|
-
|
5
|
-
def
|
6
|
-
@target = target
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.delegate_to(matcher_method)
|
4
|
+
module TargetDelegationClassMethods
|
5
|
+
def delegate_to(matcher_method)
|
10
6
|
define_method(:to) do |matcher, &block|
|
11
7
|
unless matcher_allowed?(matcher)
|
12
8
|
raise_unsupported_matcher(:to, matcher)
|
@@ -15,7 +11,7 @@ module RSpec
|
|
15
11
|
end
|
16
12
|
end
|
17
13
|
|
18
|
-
def
|
14
|
+
def delegate_not_to(matcher_method, options={})
|
19
15
|
method_name = options.fetch(:from)
|
20
16
|
define_method(method_name) do |matcher, &block|
|
21
17
|
case matcher
|
@@ -29,11 +25,16 @@ module RSpec
|
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
32
|
-
def
|
28
|
+
def disallow_negation(method_name)
|
33
29
|
define_method(method_name) do |matcher, *_args|
|
34
30
|
raise_negation_unsupported(method_name, matcher)
|
35
31
|
end
|
36
32
|
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# @private
|
36
|
+
module TargetDelegationInstanceMethods
|
37
|
+
attr_reader :target
|
37
38
|
|
38
39
|
private
|
39
40
|
|
@@ -42,7 +43,7 @@ module RSpec
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def define_matcher(matcher, name, &block)
|
45
|
-
matcher.__send__(name,
|
46
|
+
matcher.__send__(name, target, &block)
|
46
47
|
end
|
47
48
|
|
48
49
|
def raise_unsupported_matcher(method_name, matcher)
|
@@ -56,31 +57,54 @@ module RSpec
|
|
56
57
|
"`#{expression}(...).#{method_name} #{matcher.name}` is not supported since it " \
|
57
58
|
"doesn't really make sense. What would it even mean?"
|
58
59
|
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# @private
|
63
|
+
class TargetBase
|
64
|
+
def initialize(target)
|
65
|
+
@target = target
|
66
|
+
end
|
67
|
+
|
68
|
+
extend TargetDelegationClassMethods
|
69
|
+
include TargetDelegationInstanceMethods
|
70
|
+
end
|
71
|
+
|
72
|
+
# @private
|
73
|
+
module ExpectationTargetMethods
|
74
|
+
extend TargetDelegationClassMethods
|
75
|
+
include TargetDelegationInstanceMethods
|
76
|
+
|
77
|
+
delegate_to :setup_expectation
|
78
|
+
delegate_not_to :setup_negative_expectation, :from => :not_to
|
79
|
+
delegate_not_to :setup_negative_expectation, :from => :to_not
|
59
80
|
|
60
81
|
def expression
|
61
|
-
|
82
|
+
:expect
|
62
83
|
end
|
63
84
|
end
|
64
85
|
|
86
|
+
# @private
|
87
|
+
class ExpectationTarget < TargetBase
|
88
|
+
include ExpectationTargetMethods
|
89
|
+
end
|
90
|
+
|
65
91
|
# @private
|
66
92
|
class AllowanceTarget < TargetBase
|
67
|
-
|
93
|
+
def expression
|
94
|
+
:allow
|
95
|
+
end
|
96
|
+
|
68
97
|
delegate_to :setup_allowance
|
69
98
|
disallow_negation :not_to
|
70
99
|
disallow_negation :to_not
|
71
100
|
end
|
72
101
|
|
73
|
-
# @private
|
74
|
-
class ExpectationTarget < TargetBase
|
75
|
-
EXPRESSION = :expect
|
76
|
-
delegate_to :setup_expectation
|
77
|
-
delegate_not_to :setup_negative_expectation, :from => :not_to
|
78
|
-
delegate_not_to :setup_negative_expectation, :from => :to_not
|
79
|
-
end
|
80
|
-
|
81
102
|
# @private
|
82
103
|
class AnyInstanceAllowanceTarget < TargetBase
|
83
|
-
|
104
|
+
def expression
|
105
|
+
:allow_any_instance_of
|
106
|
+
end
|
107
|
+
|
84
108
|
delegate_to :setup_any_instance_allowance
|
85
109
|
disallow_negation :not_to
|
86
110
|
disallow_negation :to_not
|
@@ -88,7 +112,10 @@ module RSpec
|
|
88
112
|
|
89
113
|
# @private
|
90
114
|
class AnyInstanceExpectationTarget < TargetBase
|
91
|
-
|
115
|
+
def expression
|
116
|
+
:expect_any_instance_of
|
117
|
+
end
|
118
|
+
|
92
119
|
delegate_to :setup_any_instance_expectation
|
93
120
|
delegate_not_to :setup_any_instance_negative_expectation, :from => :not_to
|
94
121
|
delegate_not_to :setup_any_instance_negative_expectation, :from => :to_not
|
data/lib/rspec/mocks/version.rb
CHANGED
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.5.0.
|
4
|
+
version: 3.5.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Baker
|
@@ -45,7 +45,7 @@ cert_chain:
|
|
45
45
|
ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
|
46
46
|
F3MdtaDehhjC
|
47
47
|
-----END CERTIFICATE-----
|
48
|
-
date: 2016-
|
48
|
+
date: 2016-04-02 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.5.0.
|
56
|
+
version: 3.5.0.beta3
|
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.5.0.
|
63
|
+
version: 3.5.0.beta3
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
65
|
name: diff-lcs
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- lib/rspec/mocks/message_expectation.rb
|
176
176
|
- lib/rspec/mocks/method_double.rb
|
177
177
|
- lib/rspec/mocks/method_reference.rb
|
178
|
+
- lib/rspec/mocks/minitest_integration.rb
|
178
179
|
- lib/rspec/mocks/mutate_const.rb
|
179
180
|
- lib/rspec/mocks/object_reference.rb
|
180
181
|
- lib/rspec/mocks/order_group.rb
|
@@ -188,7 +189,7 @@ files:
|
|
188
189
|
- lib/rspec/mocks/verifying_message_expectation.rb
|
189
190
|
- lib/rspec/mocks/verifying_proxy.rb
|
190
191
|
- lib/rspec/mocks/version.rb
|
191
|
-
homepage:
|
192
|
+
homepage: https://github.com/rspec/rspec-mocks
|
192
193
|
licenses:
|
193
194
|
- MIT
|
194
195
|
metadata: {}
|
@@ -209,9 +210,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
210
|
version: 1.3.1
|
210
211
|
requirements: []
|
211
212
|
rubyforge_project:
|
212
|
-
rubygems_version: 2.5.1
|
213
|
+
rubygems_version: 2.4.5.1
|
213
214
|
signing_key:
|
214
215
|
specification_version: 4
|
215
|
-
summary: rspec-mocks-3.5.0.
|
216
|
+
summary: rspec-mocks-3.5.0.beta3
|
216
217
|
test_files: []
|
217
218
|
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|