rspec-mocks 3.0.0 → 3.1.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 +6 -14
- checksums.yaml.gz.sig +0 -0
- data/Changelog.md +89 -1
- data/README.md +32 -18
- data/lib/rspec/mocks/any_instance/chain.rb +2 -2
- data/lib/rspec/mocks/any_instance/expectation_chain.rb +2 -3
- data/lib/rspec/mocks/any_instance/message_chains.rb +8 -7
- data/lib/rspec/mocks/any_instance/proxy.rb +7 -3
- data/lib/rspec/mocks/any_instance/recorder.rb +27 -25
- data/lib/rspec/mocks/any_instance/stub_chain.rb +3 -5
- data/lib/rspec/mocks/argument_list_matcher.rb +4 -4
- data/lib/rspec/mocks/argument_matchers.rb +39 -6
- data/lib/rspec/mocks/configuration.rb +4 -11
- data/lib/rspec/mocks/error_generator.rb +33 -27
- data/lib/rspec/mocks/example_methods.rb +75 -7
- data/lib/rspec/mocks/instance_method_stasher.rb +5 -5
- data/lib/rspec/mocks/matchers/have_received.rb +10 -8
- data/lib/rspec/mocks/matchers/receive.rb +8 -8
- data/lib/rspec/mocks/matchers/receive_message_chain.rb +5 -6
- data/lib/rspec/mocks/matchers/receive_messages.rb +6 -7
- data/lib/rspec/mocks/message_chain.rb +5 -5
- data/lib/rspec/mocks/message_expectation.rb +66 -27
- data/lib/rspec/mocks/method_double.rb +15 -12
- data/lib/rspec/mocks/method_reference.rb +8 -7
- data/lib/rspec/mocks/mutate_const.rb +26 -100
- data/lib/rspec/mocks/object_reference.rb +12 -13
- data/lib/rspec/mocks/order_group.rb +4 -5
- data/lib/rspec/mocks/proxy.rb +35 -24
- data/lib/rspec/mocks/space.rb +25 -25
- data/lib/rspec/mocks/syntax.rb +101 -99
- data/lib/rspec/mocks/targets.rb +6 -6
- data/lib/rspec/mocks/test_double.rb +13 -4
- data/lib/rspec/mocks/verifying_double.rb +16 -16
- data/lib/rspec/mocks/verifying_message_expecation.rb +15 -13
- data/lib/rspec/mocks/verifying_proxy.rb +12 -16
- data/lib/rspec/mocks/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +61 -54
- metadata.gz.sig +0 -0
|
@@ -3,7 +3,6 @@ require 'stringio'
|
|
|
3
3
|
|
|
4
4
|
module RSpec
|
|
5
5
|
module Mocks
|
|
6
|
-
|
|
7
6
|
# @private
|
|
8
7
|
module VerifyingDouble
|
|
9
8
|
def respond_to?(message, include_private=false)
|
|
@@ -11,11 +10,11 @@ module RSpec
|
|
|
11
10
|
|
|
12
11
|
method_ref = __mock_proxy.method_reference[message]
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
case method_ref.visibility
|
|
14
|
+
when :public then true
|
|
15
|
+
when :private then include_private
|
|
16
|
+
when :protected then include_private || RUBY_VERSION.to_f < 2.0
|
|
17
|
+
else !method_ref.unimplemented?
|
|
19
18
|
end
|
|
20
19
|
end
|
|
21
20
|
|
|
@@ -74,8 +73,8 @@ module RSpec
|
|
|
74
73
|
|
|
75
74
|
def __build_mock_proxy(order_group)
|
|
76
75
|
VerifyingProxy.new(self, order_group, @name,
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
@doubled_module,
|
|
77
|
+
InstanceMethodReference
|
|
79
78
|
)
|
|
80
79
|
end
|
|
81
80
|
end
|
|
@@ -88,6 +87,13 @@ module RSpec
|
|
|
88
87
|
include TestDouble
|
|
89
88
|
include VerifyingDouble
|
|
90
89
|
|
|
90
|
+
def as_stubbed_const(options={})
|
|
91
|
+
ConstantMutator.stub(@doubled_module.const_to_replace, self, options)
|
|
92
|
+
self
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
private
|
|
96
|
+
|
|
91
97
|
def initialize(doubled_module, *args)
|
|
92
98
|
@doubled_module = doubled_module
|
|
93
99
|
super(doubled_module.description, *args)
|
|
@@ -95,15 +101,10 @@ module RSpec
|
|
|
95
101
|
|
|
96
102
|
def __build_mock_proxy(order_group)
|
|
97
103
|
VerifyingProxy.new(self, order_group, @name,
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
@doubled_module,
|
|
105
|
+
ObjectMethodReference
|
|
100
106
|
)
|
|
101
107
|
end
|
|
102
|
-
|
|
103
|
-
def as_stubbed_const(options = {})
|
|
104
|
-
ConstantMutator.stub(@doubled_module.const_to_replace, self, options)
|
|
105
|
-
self
|
|
106
|
-
end
|
|
107
108
|
end
|
|
108
109
|
|
|
109
110
|
# Similar to an InstanceVerifyingDouble, except that it verifies against
|
|
@@ -122,6 +123,5 @@ module RSpec
|
|
|
122
123
|
class ClassVerifyingDouble < Module
|
|
123
124
|
include ObjectVerifyingDoubleMethods
|
|
124
125
|
end
|
|
125
|
-
|
|
126
126
|
end
|
|
127
127
|
end
|
|
@@ -2,13 +2,11 @@ RSpec::Support.require_rspec_support 'method_signature_verifier'
|
|
|
2
2
|
|
|
3
3
|
module RSpec
|
|
4
4
|
module Mocks
|
|
5
|
-
|
|
6
5
|
# A message expectation that knows about the real implementation of the
|
|
7
6
|
# message being expected, so that it can verify that any expectations
|
|
8
7
|
# have the valid arguments.
|
|
9
8
|
# @api private
|
|
10
9
|
class VerifyingMessageExpectation < MessageExpectation
|
|
11
|
-
|
|
12
10
|
# A level of indirection is used here rather than just passing in the
|
|
13
11
|
# method itself, since method look up is expensive and we only want to
|
|
14
12
|
# do it if actually needed.
|
|
@@ -27,26 +25,30 @@ module RSpec
|
|
|
27
25
|
def with(*args, &block)
|
|
28
26
|
unless ArgumentMatchers::AnyArgsMatcher === args.first
|
|
29
27
|
expected_args = if ArgumentMatchers::NoArgsMatcher === args.first
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
[]
|
|
29
|
+
elsif args.length > 0
|
|
30
|
+
args
|
|
31
|
+
else
|
|
32
|
+
# No arguments given, this will raise.
|
|
33
|
+
super
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
validate_expected_arguments!(expected_args)
|
|
39
37
|
end
|
|
40
38
|
super
|
|
41
39
|
end
|
|
42
40
|
|
|
43
41
|
private
|
|
44
42
|
|
|
45
|
-
def
|
|
43
|
+
def validate_expected_arguments!(actual_args)
|
|
46
44
|
return if method_reference.nil?
|
|
47
45
|
|
|
48
46
|
method_reference.with_signature do |signature|
|
|
49
|
-
verifier = Support::
|
|
47
|
+
verifier = Support::LooseSignatureVerifier.new(
|
|
48
|
+
signature,
|
|
49
|
+
actual_args
|
|
50
|
+
)
|
|
51
|
+
|
|
50
52
|
unless verifier.valid?
|
|
51
53
|
# Fail fast is required, otherwise the message expecation will fail
|
|
52
54
|
# as well ("expected method not called") and clobber this one.
|
|
@@ -3,7 +3,6 @@ RSpec::Support.require_rspec_mocks 'method_reference'
|
|
|
3
3
|
|
|
4
4
|
module RSpec
|
|
5
5
|
module Mocks
|
|
6
|
-
|
|
7
6
|
# @private
|
|
8
7
|
module VerifyingProxyMethods
|
|
9
8
|
def add_stub(method_name, opts={}, &implementation)
|
|
@@ -22,21 +21,20 @@ module RSpec
|
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
def ensure_implemented(method_name)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
return unless method_reference[method_name].unimplemented?
|
|
25
|
+
|
|
26
|
+
@error_generator.raise_unimplemented_error(
|
|
27
|
+
@doubled_module,
|
|
28
|
+
method_name
|
|
29
|
+
)
|
|
31
30
|
end
|
|
32
31
|
|
|
33
|
-
def ensure_publicly_implemented(method_name,
|
|
32
|
+
def ensure_publicly_implemented(method_name, _object)
|
|
34
33
|
ensure_implemented(method_name)
|
|
35
34
|
visibility = method_reference[method_name].visibility
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
end
|
|
36
|
+
return if visibility == :public
|
|
37
|
+
@error_generator.raise_non_public_error(method_name, visibility)
|
|
40
38
|
end
|
|
41
39
|
end
|
|
42
40
|
|
|
@@ -54,7 +52,7 @@ module RSpec
|
|
|
54
52
|
# isolation.
|
|
55
53
|
#
|
|
56
54
|
# @private
|
|
57
|
-
class VerifyingProxy <
|
|
55
|
+
class VerifyingProxy < TestDoubleProxy
|
|
58
56
|
include VerifyingProxyMethods
|
|
59
57
|
|
|
60
58
|
def initialize(object, order_group, name, doubled_module, method_reference_class)
|
|
@@ -132,10 +130,8 @@ module RSpec
|
|
|
132
130
|
|
|
133
131
|
def validate_arguments!(actual_args)
|
|
134
132
|
@method_reference.with_signature do |signature|
|
|
135
|
-
verifier = Support::
|
|
136
|
-
unless verifier.valid?
|
|
137
|
-
raise ArgumentError, verifier.error_message
|
|
138
|
-
end
|
|
133
|
+
verifier = Support::StrictSignatureVerifier.new(signature, actual_args)
|
|
134
|
+
raise ArgumentError, verifier.error_message unless verifier.valid?
|
|
139
135
|
end
|
|
140
136
|
end
|
|
141
137
|
end
|
data/lib/rspec/mocks/version.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
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
|
+
version: 3.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steven Baker
|
|
@@ -10,100 +10,112 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain:
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
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
|
22
|
+
RUCvuhQ3klatYk4jF+cGt1jNONNVdLOiy0bMynvcM7hoVQ2AomwGs+cEOWQ/4dkD
|
|
23
|
+
JcNV3qfzF5QBcTD2372XNM53b25nYVQSX2KH5FF7BhlKyov33bOm2gA9M+mWIujW
|
|
24
|
+
qgkyxVlfrlE+ZBgV3wXn1Cojg1LpTq35yOArgwioyrwwlZZJR9joN9s/nDklfr5A
|
|
25
|
+
+dyETjFc6cmEPWZrt2cJBQIDAQABo4GGMIGDMAkGA1UdEwQCMAAwCwYDVR0PBAQD
|
|
26
|
+
AgSwMB0GA1UdDgQWBBSW+WD7hn1swJ1A7i8tbuFeuNCJCjAkBgNVHREEHTAbgRly
|
|
27
|
+
c3BlYy1kZXZAZ29vZ2xlZ291cHMuY29tMCQGA1UdEgQdMBuBGXJzcGVjLWRldkBn
|
|
28
|
+
b29nbGVnb3Vwcy5jb20wDQYJKoZIhvcNAQEFBQADggEBAH27jAZ8sD7vnXupj6Y+
|
|
29
|
+
BaBdfHtCkFaslLJ0aKuMDIVXwYuKfqoW15cZPDLmSIEBuQFM3lw6d/hEEL4Uo2jZ
|
|
30
|
+
FvtmH5OxifPDzFyUtCL4yp6qgNe/Xf6sDsRg6FmKcpgqCwNOmsViaf0LPSUH/GYQ
|
|
31
|
+
3Teoz8QCaDbD7AKsffT7eDrnbHnKweO1XdemRJC98u/yYxnGzMSWKEsn09etBlZ9
|
|
32
|
+
7H67k5Z3uf6cfLZgToWL6zShzZY3Nun5r73YsNf2/QZOe4UZe4vfGvn6baw53ys9
|
|
33
|
+
1yHC1AcSYpvi2dAbOiHT5iQF+krm4wse8KctXgTNnjMsHEoGKulJS2/sZl90jcCz
|
|
34
|
+
muA=
|
|
35
|
+
-----END CERTIFICATE-----
|
|
36
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
|
44
37
|
dependencies:
|
|
45
38
|
- !ruby/object:Gem::Dependency
|
|
46
39
|
name: rspec-support
|
|
47
40
|
requirement: !ruby/object:Gem::Requirement
|
|
48
41
|
requirements:
|
|
49
|
-
- - ~>
|
|
42
|
+
- - "~>"
|
|
50
43
|
- !ruby/object:Gem::Version
|
|
51
|
-
version: 3.
|
|
44
|
+
version: 3.1.0
|
|
52
45
|
type: :runtime
|
|
53
46
|
prerelease: false
|
|
54
47
|
version_requirements: !ruby/object:Gem::Requirement
|
|
55
48
|
requirements:
|
|
56
|
-
- - ~>
|
|
49
|
+
- - "~>"
|
|
57
50
|
- !ruby/object:Gem::Version
|
|
58
|
-
version: 3.
|
|
51
|
+
version: 3.1.0
|
|
59
52
|
- !ruby/object:Gem::Dependency
|
|
60
53
|
name: rake
|
|
61
54
|
requirement: !ruby/object:Gem::Requirement
|
|
62
55
|
requirements:
|
|
63
|
-
- - ~>
|
|
56
|
+
- - "~>"
|
|
64
57
|
- !ruby/object:Gem::Version
|
|
65
58
|
version: 10.0.0
|
|
66
59
|
type: :development
|
|
67
60
|
prerelease: false
|
|
68
61
|
version_requirements: !ruby/object:Gem::Requirement
|
|
69
62
|
requirements:
|
|
70
|
-
- - ~>
|
|
63
|
+
- - "~>"
|
|
71
64
|
- !ruby/object:Gem::Version
|
|
72
65
|
version: 10.0.0
|
|
73
66
|
- !ruby/object:Gem::Dependency
|
|
74
67
|
name: cucumber
|
|
75
68
|
requirement: !ruby/object:Gem::Requirement
|
|
76
69
|
requirements:
|
|
77
|
-
- - ~>
|
|
70
|
+
- - "~>"
|
|
78
71
|
- !ruby/object:Gem::Version
|
|
79
|
-
version: 1.
|
|
72
|
+
version: 1.3.15
|
|
80
73
|
type: :development
|
|
81
74
|
prerelease: false
|
|
82
75
|
version_requirements: !ruby/object:Gem::Requirement
|
|
83
76
|
requirements:
|
|
84
|
-
- - ~>
|
|
77
|
+
- - "~>"
|
|
85
78
|
- !ruby/object:Gem::Version
|
|
86
|
-
version: 1.
|
|
79
|
+
version: 1.3.15
|
|
87
80
|
- !ruby/object:Gem::Dependency
|
|
88
81
|
name: aruba
|
|
89
82
|
requirement: !ruby/object:Gem::Requirement
|
|
90
83
|
requirements:
|
|
91
|
-
- - ~>
|
|
84
|
+
- - "~>"
|
|
92
85
|
- !ruby/object:Gem::Version
|
|
93
86
|
version: '0.5'
|
|
94
87
|
type: :development
|
|
95
88
|
prerelease: false
|
|
96
89
|
version_requirements: !ruby/object:Gem::Requirement
|
|
97
90
|
requirements:
|
|
98
|
-
- - ~>
|
|
91
|
+
- - "~>"
|
|
99
92
|
- !ruby/object:Gem::Version
|
|
100
93
|
version: '0.5'
|
|
94
|
+
- !ruby/object:Gem::Dependency
|
|
95
|
+
name: minitest
|
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
|
97
|
+
requirements:
|
|
98
|
+
- - "~>"
|
|
99
|
+
- !ruby/object:Gem::Version
|
|
100
|
+
version: '5.2'
|
|
101
|
+
type: :development
|
|
102
|
+
prerelease: false
|
|
103
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
104
|
+
requirements:
|
|
105
|
+
- - "~>"
|
|
106
|
+
- !ruby/object:Gem::Version
|
|
107
|
+
version: '5.2'
|
|
101
108
|
description: RSpec's 'test double' framework, with support for stubbing and mocking
|
|
102
109
|
email: rspec@googlegroups.com
|
|
103
110
|
executables: []
|
|
104
111
|
extensions: []
|
|
105
112
|
extra_rdoc_files: []
|
|
106
113
|
files:
|
|
114
|
+
- ".document"
|
|
115
|
+
- ".yardopts"
|
|
116
|
+
- Changelog.md
|
|
117
|
+
- License.txt
|
|
118
|
+
- README.md
|
|
107
119
|
- lib/rspec/mocks.rb
|
|
108
120
|
- lib/rspec/mocks/any_instance.rb
|
|
109
121
|
- lib/rspec/mocks/any_instance/chain.rb
|
|
@@ -143,35 +155,30 @@ files:
|
|
|
143
155
|
- lib/rspec/mocks/verifying_message_expecation.rb
|
|
144
156
|
- lib/rspec/mocks/verifying_proxy.rb
|
|
145
157
|
- lib/rspec/mocks/version.rb
|
|
146
|
-
- README.md
|
|
147
|
-
- License.txt
|
|
148
|
-
- Changelog.md
|
|
149
|
-
- .yardopts
|
|
150
|
-
- .document
|
|
151
158
|
homepage: http://github.com/rspec/rspec-mocks
|
|
152
159
|
licenses:
|
|
153
160
|
- MIT
|
|
154
161
|
metadata: {}
|
|
155
162
|
post_install_message:
|
|
156
163
|
rdoc_options:
|
|
157
|
-
- --charset=UTF-8
|
|
164
|
+
- "--charset=UTF-8"
|
|
158
165
|
require_paths:
|
|
159
166
|
- lib
|
|
160
167
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
168
|
requirements:
|
|
162
|
-
- -
|
|
169
|
+
- - ">="
|
|
163
170
|
- !ruby/object:Gem::Version
|
|
164
171
|
version: 1.8.7
|
|
165
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
173
|
requirements:
|
|
167
|
-
- -
|
|
174
|
+
- - ">="
|
|
168
175
|
- !ruby/object:Gem::Version
|
|
169
176
|
version: '0'
|
|
170
177
|
requirements: []
|
|
171
178
|
rubyforge_project: rspec
|
|
172
|
-
rubygems_version: 2.
|
|
179
|
+
rubygems_version: 2.2.2
|
|
173
180
|
signing_key:
|
|
174
181
|
specification_version: 4
|
|
175
|
-
summary: rspec-mocks-3.
|
|
182
|
+
summary: rspec-mocks-3.1.0
|
|
176
183
|
test_files: []
|
|
177
184
|
has_rdoc:
|
metadata.gz.sig
CHANGED
|
Binary file
|