rspec-mocks 2.10.1 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.md +26 -1
- data/README.md +14 -2
- data/features/stubbing_constants/README.md +62 -0
- data/features/stubbing_constants/stub_defined_constant.feature +79 -0
- data/features/stubbing_constants/stub_undefined_constant.feature +50 -0
- data/lib/rspec/mocks/any_instance.rb +37 -1
- data/lib/rspec/mocks/any_instance/chain.rb +0 -81
- data/lib/rspec/mocks/any_instance/expectation_chain.rb +57 -0
- data/lib/rspec/mocks/any_instance/recorder.rb +6 -1
- data/lib/rspec/mocks/any_instance/stub_chain.rb +37 -0
- data/lib/rspec/mocks/any_instance/stub_chain_chain.rb +25 -0
- data/lib/rspec/mocks/argument_list_matcher.rb +93 -0
- data/lib/rspec/mocks/argument_matchers.rb +39 -31
- data/lib/rspec/mocks/error_generator.rb +7 -0
- data/lib/rspec/mocks/example_methods.rb +41 -0
- data/lib/rspec/mocks/framework.rb +2 -1
- data/lib/rspec/mocks/message_expectation.rb +21 -13
- data/lib/rspec/mocks/methods.rb +4 -0
- data/lib/rspec/mocks/proxy.rb +10 -4
- data/lib/rspec/mocks/stub_const.rb +280 -0
- data/lib/rspec/mocks/test_double.rb +3 -2
- data/lib/rspec/mocks/version.rb +1 -1
- data/spec/rspec/mocks/any_instance/message_chains_spec.rb +1 -1
- data/spec/rspec/mocks/any_instance_spec.rb +66 -26
- data/spec/rspec/mocks/argument_expectation_spec.rb +7 -7
- data/spec/rspec/mocks/at_least_spec.rb +14 -0
- data/spec/rspec/mocks/block_return_value_spec.rb +8 -0
- data/spec/rspec/mocks/mock_spec.rb +33 -20
- data/spec/rspec/mocks/multiple_return_value_spec.rb +2 -2
- data/spec/rspec/mocks/null_object_mock_spec.rb +22 -0
- data/spec/rspec/mocks/stub_chain_spec.rb +45 -45
- data/spec/rspec/mocks/stub_const_spec.rb +309 -0
- data/spec/rspec/mocks/stub_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -40
- metadata +18 -6
- data/lib/rspec/mocks/argument_expectation.rb +0 -52
@@ -208,10 +208,10 @@ module RSpec
|
|
208
208
|
end.should raise_error(/received :foo with unexpected arguments/)
|
209
209
|
end
|
210
210
|
|
211
|
-
it "complains if called with other arg" do
|
211
|
+
it "complains if called with other arg", :github_issue => [123,147] do
|
212
212
|
lambda do
|
213
213
|
@stub.foo("other")
|
214
|
-
end.should raise_error(/received :foo with unexpected arguments/)
|
214
|
+
end.should raise_error(/received :foo with unexpected arguments.*Please stub a default value/m)
|
215
215
|
end
|
216
216
|
|
217
217
|
it "does not complain if also mocked w/ different args" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,32 +1,3 @@
|
|
1
|
-
require 'rspec/core'
|
2
|
-
require 'rspec/mocks'
|
3
|
-
require 'rspec/expectations'
|
4
|
-
|
5
|
-
module Macros
|
6
|
-
def treats_method_missing_as_private(options = {:noop => true, :subject => nil})
|
7
|
-
it "has method_missing as private" do
|
8
|
-
self.class.describes.private_instance_methods.should include_method(:method_missing)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "does not respond_to? method_missing (because it's private)" do
|
12
|
-
formatter = options[:subject] || described_class.new({ }, StringIO.new)
|
13
|
-
formatter.should_not respond_to(:method_missing)
|
14
|
-
end
|
15
|
-
|
16
|
-
if options[:noop]
|
17
|
-
it "should respond_to? all messages" do
|
18
|
-
formatter = described_class.new({ }, StringIO.new)
|
19
|
-
formatter.should respond_to(:just_about_anything)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should respond_to? anything, when given the private flag" do
|
23
|
-
formatter = described_class.new({ }, StringIO.new)
|
24
|
-
formatter.respond_to?(:method_missing, true).should be_true
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
1
|
RSpec::Matchers.define :include_method do |expected|
|
31
2
|
match do |actual|
|
32
3
|
actual.map { |m| m.to_s }.include?(expected.to_s)
|
@@ -37,19 +8,8 @@ RSpec.configure do |config|
|
|
37
8
|
config.mock_with :rspec
|
38
9
|
config.color_enabled = true
|
39
10
|
config.order = :random
|
40
|
-
config.extend(Macros)
|
41
11
|
config.include(RSpec::Mocks::Methods)
|
42
12
|
config.run_all_when_everything_filtered = true
|
43
13
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
44
14
|
config.filter_run_including :focus
|
45
|
-
config.filter_run_excluding :ruby => lambda {|version|
|
46
|
-
case version.to_s
|
47
|
-
when "!jruby"
|
48
|
-
RUBY_ENGINE != "jruby"
|
49
|
-
when /^> (.*)/
|
50
|
-
!(RUBY_VERSION.to_s > $1)
|
51
|
-
else
|
52
|
-
!(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
|
53
|
-
end
|
54
|
-
}
|
55
15
|
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: 2.
|
4
|
+
version: 2.11.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-07-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -69,9 +69,12 @@ files:
|
|
69
69
|
- lib/rspec/mocks.rb
|
70
70
|
- lib/rspec/mocks/any_instance.rb
|
71
71
|
- lib/rspec/mocks/any_instance/chain.rb
|
72
|
+
- lib/rspec/mocks/any_instance/expectation_chain.rb
|
72
73
|
- lib/rspec/mocks/any_instance/message_chains.rb
|
73
74
|
- lib/rspec/mocks/any_instance/recorder.rb
|
74
|
-
- lib/rspec/mocks/
|
75
|
+
- lib/rspec/mocks/any_instance/stub_chain.rb
|
76
|
+
- lib/rspec/mocks/any_instance/stub_chain_chain.rb
|
77
|
+
- lib/rspec/mocks/argument_list_matcher.rb
|
75
78
|
- lib/rspec/mocks/argument_matchers.rb
|
76
79
|
- lib/rspec/mocks/error_generator.rb
|
77
80
|
- lib/rspec/mocks/errors.rb
|
@@ -89,6 +92,7 @@ files:
|
|
89
92
|
- lib/rspec/mocks/serialization.rb
|
90
93
|
- lib/rspec/mocks/space.rb
|
91
94
|
- lib/rspec/mocks/standalone.rb
|
95
|
+
- lib/rspec/mocks/stub_const.rb
|
92
96
|
- lib/rspec/mocks/test_double.rb
|
93
97
|
- lib/rspec/mocks/version.rb
|
94
98
|
- lib/spec/mocks.rb
|
@@ -120,6 +124,9 @@ files:
|
|
120
124
|
- features/outside_rspec/configuration.feature
|
121
125
|
- features/outside_rspec/standalone.feature
|
122
126
|
- features/step_definitions/additional_cli_steps.rb
|
127
|
+
- features/stubbing_constants/README.md
|
128
|
+
- features/stubbing_constants/stub_defined_constant.feature
|
129
|
+
- features/stubbing_constants/stub_undefined_constant.feature
|
123
130
|
- features/support/env.rb
|
124
131
|
- spec/rspec/mocks/and_yield_spec.rb
|
125
132
|
- spec/rspec/mocks/any_instance/message_chains_spec.rb
|
@@ -158,6 +165,7 @@ files:
|
|
158
165
|
- spec/rspec/mocks/serialization_spec.rb
|
159
166
|
- spec/rspec/mocks/stash_spec.rb
|
160
167
|
- spec/rspec/mocks/stub_chain_spec.rb
|
168
|
+
- spec/rspec/mocks/stub_const_spec.rb
|
161
169
|
- spec/rspec/mocks/stub_implementation_spec.rb
|
162
170
|
- spec/rspec/mocks/stub_spec.rb
|
163
171
|
- spec/rspec/mocks/stubbed_message_expectations_spec.rb
|
@@ -182,7 +190,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
190
|
version: '0'
|
183
191
|
segments:
|
184
192
|
- 0
|
185
|
-
hash:
|
193
|
+
hash: 1632544807063438503
|
186
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
195
|
none: false
|
188
196
|
requirements:
|
@@ -191,13 +199,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
199
|
version: '0'
|
192
200
|
segments:
|
193
201
|
- 0
|
194
|
-
hash:
|
202
|
+
hash: 1632544807063438503
|
195
203
|
requirements: []
|
196
204
|
rubyforge_project: rspec
|
197
205
|
rubygems_version: 1.8.24
|
198
206
|
signing_key:
|
199
207
|
specification_version: 3
|
200
|
-
summary: rspec-mocks-2.
|
208
|
+
summary: rspec-mocks-2.11.0
|
201
209
|
test_files:
|
202
210
|
- features/README.md
|
203
211
|
- features/Scope.md
|
@@ -222,6 +230,9 @@ test_files:
|
|
222
230
|
- features/outside_rspec/configuration.feature
|
223
231
|
- features/outside_rspec/standalone.feature
|
224
232
|
- features/step_definitions/additional_cli_steps.rb
|
233
|
+
- features/stubbing_constants/README.md
|
234
|
+
- features/stubbing_constants/stub_defined_constant.feature
|
235
|
+
- features/stubbing_constants/stub_undefined_constant.feature
|
225
236
|
- features/support/env.rb
|
226
237
|
- spec/rspec/mocks/and_yield_spec.rb
|
227
238
|
- spec/rspec/mocks/any_instance/message_chains_spec.rb
|
@@ -260,6 +271,7 @@ test_files:
|
|
260
271
|
- spec/rspec/mocks/serialization_spec.rb
|
261
272
|
- spec/rspec/mocks/stash_spec.rb
|
262
273
|
- spec/rspec/mocks/stub_chain_spec.rb
|
274
|
+
- spec/rspec/mocks/stub_const_spec.rb
|
263
275
|
- spec/rspec/mocks/stub_implementation_spec.rb
|
264
276
|
- spec/rspec/mocks/stub_spec.rb
|
265
277
|
- spec/rspec/mocks/stubbed_message_expectations_spec.rb
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module RSpec
|
2
|
-
module Mocks
|
3
|
-
# @api private
|
4
|
-
class ArgumentExpectation
|
5
|
-
attr_reader :args
|
6
|
-
|
7
|
-
def initialize(*args, &block)
|
8
|
-
@args = args
|
9
|
-
@block = args.empty? ? block : nil
|
10
|
-
@match_any_args = false
|
11
|
-
@matchers = nil
|
12
|
-
|
13
|
-
case args.first
|
14
|
-
when ArgumentMatchers::AnyArgsMatcher
|
15
|
-
@match_any_args = true
|
16
|
-
when ArgumentMatchers::NoArgsMatcher
|
17
|
-
@matchers = []
|
18
|
-
else
|
19
|
-
@matchers = args.collect {|arg| matcher_for(arg)}
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def matcher_for(arg)
|
24
|
-
return ArgumentMatchers::MatcherMatcher.new(arg) if is_matcher?(arg)
|
25
|
-
return ArgumentMatchers::RegexpMatcher.new(arg) if arg.is_a?(Regexp)
|
26
|
-
return ArgumentMatchers::EqualityProxy.new(arg)
|
27
|
-
end
|
28
|
-
|
29
|
-
def is_matcher?(obj)
|
30
|
-
!obj.null_object? & obj.respond_to?(:matches?) & [:failure_message_for_should, :failure_message].any? { |m| obj.respond_to?(m) }
|
31
|
-
end
|
32
|
-
|
33
|
-
def args_match?(*args)
|
34
|
-
match_any_args? || block_passes?(*args) || matchers_match?(*args)
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def block_passes?(*args)
|
40
|
-
@block.call(*args) if @block
|
41
|
-
end
|
42
|
-
|
43
|
-
def matchers_match?(*args)
|
44
|
-
@matchers == args
|
45
|
-
end
|
46
|
-
|
47
|
-
def match_any_args?
|
48
|
-
@match_any_args
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|