rr 1.2.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES.md +25 -0
- data/Gemfile +1 -8
- data/README.md +8 -13
- data/Rakefile +16 -6
- data/lib/rr/class_instance_method_defined.rb +1 -1
- data/lib/rr/double.rb +28 -10
- data/lib/rr/double_definitions/double_definition.rb +39 -16
- data/lib/rr/double_definitions/double_definition_create.rb +5 -5
- data/lib/rr/double_definitions/double_definition_create_blank_slate.rb +10 -4
- data/lib/rr/double_definitions/strategies/strategy.rb +27 -8
- data/lib/rr/double_definitions/strategies/verification/mock.rb +8 -2
- data/lib/rr/double_matches.rb +4 -3
- data/lib/rr/expectations/any_argument_expectation.rb +4 -4
- data/lib/rr/expectations/argument_equality_expectation.rb +43 -5
- data/lib/rr/injections/double_injection.rb +65 -18
- data/lib/rr/injections/method_missing_injection.rb +36 -9
- data/lib/rr/keyword_arguments.rb +15 -0
- data/lib/rr/method_dispatches/base_method_dispatch.rb +22 -5
- data/lib/rr/method_dispatches/method_dispatch.rb +21 -10
- data/lib/rr/method_dispatches/method_missing_dispatch.rb +14 -5
- data/lib/rr/recorded_call.rb +9 -3
- data/lib/rr/recorded_calls.rb +17 -7
- data/lib/rr/space.rb +15 -5
- data/lib/rr/version.rb +1 -1
- data/lib/rr/without_autohook.rb +2 -1
- data/rr.gemspec +5 -0
- data/spec/suites.yml +1 -15
- data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_spec.rb +18 -18
- data/spec/suites/rspec_2/unit/expectations/any_argument_expectation_spec.rb +9 -9
- data/spec/suites/rspec_2/unit/expectations/argument_equality_expectation_spec.rb +21 -21
- data/spec/suites/rspec_2/unit/expectations/boolean_argument_equality_expectation_spec.rb +4 -4
- data/spec/suites/rspec_2/unit/expectations/hash_including_argument_equality_expectation_spec.rb +31 -21
- data/spec/suites/rspec_2/unit/space_spec.rb +4 -3
- metadata +61 -10
- data/lib/rr/proc_from_block.rb +0 -11
- data/spec/suites/rspec_2/unit/proc_from_block_spec.rb +0 -14
- data/spec/suites/rspec_2_rails_4/integration/astc_rails_4_spec.rb +0 -142
- data/spec/suites/rspec_2_rails_4/integration/minitest_4_rails_4_spec.rb +0 -149
- data/spec/suites/rspec_2_rails_4/spec_helper.rb +0 -3
data/lib/rr/recorded_call.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
module RR
|
2
|
-
class RecordedCall < Struct.new(:subject,
|
2
|
+
class RecordedCall < Struct.new(:subject,
|
3
|
+
:method_name,
|
4
|
+
:arguments,
|
5
|
+
:keyword_arguments,
|
6
|
+
:block)
|
3
7
|
def inspect
|
4
|
-
'[%s, %s, %s, %s]' % [
|
8
|
+
'[%s, %s, %s, %s, %s]' % [
|
5
9
|
subject_to_s,
|
6
10
|
method_name.inspect,
|
7
11
|
arguments.inspect,
|
12
|
+
keyword_arguments.inspect,
|
8
13
|
block.inspect
|
9
14
|
]
|
10
15
|
end
|
@@ -13,7 +18,8 @@ module RR
|
|
13
18
|
other.is_a?(self.class) &&
|
14
19
|
subject == other.subject &&
|
15
20
|
method_name == other.method_name &&
|
16
|
-
arguments == other.arguments
|
21
|
+
arguments == other.arguments &&
|
22
|
+
keyword_arguments == other.keyword_arguments
|
17
23
|
end
|
18
24
|
|
19
25
|
private
|
data/lib/rr/recorded_calls.rb
CHANGED
@@ -18,8 +18,12 @@ module RR
|
|
18
18
|
recorded_calls.clear
|
19
19
|
end
|
20
20
|
|
21
|
-
def add(subject, method_name, arguments, block)
|
22
|
-
recorded_calls << RecordedCall.new(subject,
|
21
|
+
def add(subject, method_name, arguments, keyword_arguments, block)
|
22
|
+
recorded_calls << RecordedCall.new(subject,
|
23
|
+
method_name,
|
24
|
+
arguments,
|
25
|
+
keyword_arguments,
|
26
|
+
block)
|
23
27
|
end
|
24
28
|
|
25
29
|
def any?(&block)
|
@@ -81,22 +85,28 @@ module RR
|
|
81
85
|
|
82
86
|
def match_double_injection(spy_verification)
|
83
87
|
lambda do |recorded_call|
|
84
|
-
recorded_call
|
85
|
-
|
88
|
+
recorded_call.subject == spy_verification.subject &&
|
89
|
+
recorded_call.method_name == spy_verification.method_name
|
86
90
|
end
|
87
91
|
end
|
88
92
|
|
89
93
|
def match_argument_expectation(spy_verification)
|
90
94
|
lambda do |recorded_call|
|
91
|
-
spy_verification.argument_expectation
|
92
|
-
|
95
|
+
expectation = spy_verification.argument_expectation
|
96
|
+
arguments = recorded_call.arguments
|
97
|
+
keyword_arguments = recorded_call.keyword_arguments
|
98
|
+
expectation.exact_match?(arguments, keyword_arguments) ||
|
99
|
+
expectation.wildcard_match?(arguments, keyword_arguments)
|
93
100
|
end
|
94
101
|
end
|
95
102
|
|
96
103
|
def invocation_count_error(spy_verification, matching_recorded_calls)
|
104
|
+
method_name = spy_verification.method_name
|
105
|
+
arguments = spy_verification.argument_expectation.expected_arguments
|
106
|
+
keyword_arguments = spy_verification.argument_expectation.expected_keyword_arguments
|
97
107
|
RR::Errors.build_error(RR::Errors::SpyVerificationErrors::InvocationCountError,
|
98
108
|
"On subject #{spy_verification.subject.inspect}\n" <<
|
99
|
-
"Expected #{Double.formatted_name(
|
109
|
+
"Expected #{Double.formatted_name(method_name, arguments, keyword_arguments)}\n" <<
|
100
110
|
"to be called #{spy_verification.times_matcher.expected_times_message},\n" <<
|
101
111
|
"but was called #{matching_recorded_calls.size} times.\n" <<
|
102
112
|
"All of the method calls related to Doubles are:\n" <<
|
data/lib/rr/space.rb
CHANGED
@@ -13,9 +13,15 @@ module RR
|
|
13
13
|
end
|
14
14
|
attr_writer :instance
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
protected
|
17
|
+
if KeywordArguments.fully_supported?
|
18
|
+
def method_missing(method_name, *args, **kwargs, &block)
|
19
|
+
instance.__send__(method_name, *args, **kwargs, &block)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
def method_missing(method_name, *args, &block)
|
23
|
+
instance.__send__(method_name, *args, &block)
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
21
27
|
|
@@ -79,8 +85,12 @@ module RR
|
|
79
85
|
Injections::DoubleInjection.reset_double(class << subject; self; end, method_name)
|
80
86
|
end
|
81
87
|
|
82
|
-
def record_call(subject, method_name, arguments, block)
|
83
|
-
@recorded_calls.add(subject,
|
88
|
+
def record_call(subject, method_name, arguments, keyword_arguments, block)
|
89
|
+
@recorded_calls.add(subject,
|
90
|
+
method_name,
|
91
|
+
arguments,
|
92
|
+
keyword_arguments,
|
93
|
+
block)
|
84
94
|
end
|
85
95
|
|
86
96
|
def blank_slate_whitelist
|
data/lib/rr/version.rb
CHANGED
data/lib/rr/without_autohook.rb
CHANGED
@@ -6,6 +6,8 @@ require 'rr/core_ext/array'
|
|
6
6
|
require 'rr/core_ext/range'
|
7
7
|
require 'rr/core_ext/regexp'
|
8
8
|
|
9
|
+
require 'rr/keyword_arguments'
|
10
|
+
|
9
11
|
require 'rr/class_instance_method_defined'
|
10
12
|
require 'rr/blank_slate'
|
11
13
|
|
@@ -51,7 +53,6 @@ require 'rr/method_dispatches/method_missing_dispatch'
|
|
51
53
|
require 'rr/hash_with_object_id_key'
|
52
54
|
require 'rr/recorded_call'
|
53
55
|
require 'rr/recorded_calls'
|
54
|
-
require 'rr/proc_from_block'
|
55
56
|
|
56
57
|
require 'rr/double_definitions/double_definition_create_blank_slate'
|
57
58
|
require 'rr/double_definitions/double_definition_create'
|
data/rr.gemspec
CHANGED
@@ -29,4 +29,9 @@ Gem::Specification.new do |gem|
|
|
29
29
|
].to_a
|
30
30
|
|
31
31
|
gem.require_paths = ['lib']
|
32
|
+
|
33
|
+
gem.add_development_dependency("bundler")
|
34
|
+
gem.add_development_dependency("rake")
|
35
|
+
gem.add_development_dependency("test-unit")
|
36
|
+
gem.add_development_dependency("test-unit-rr")
|
32
37
|
end
|
data/spec/suites.yml
CHANGED
@@ -1,13 +1,3 @@
|
|
1
|
-
18:
|
2
|
-
rvm_versions:
|
3
|
-
- name: 1.8.7
|
4
|
-
suites:
|
5
|
-
- name: rspec_1
|
6
|
-
desc: 'RSpec 1'
|
7
|
-
- name: rspec_1_rails_2
|
8
|
-
desc: 'RSpec 1 + Rails 2'
|
9
|
-
env:
|
10
|
-
SPEC_OPTS: '--require $PWD/spec/custom_formatter_for_rspec --format CustomFormatterForRSpec --backtrace'
|
11
1
|
19:
|
12
2
|
rvm_versions:
|
13
3
|
- name: 1.9.3
|
@@ -16,9 +6,5 @@
|
|
16
6
|
suites:
|
17
7
|
- name: rspec_2
|
18
8
|
desc: 'RSpec 2'
|
19
|
-
- name: rspec_2_rails_3
|
20
|
-
desc: 'RSpec 2 + Rails 3'
|
21
|
-
- name: rspec_2_rails_4
|
22
|
-
desc: 'RSpec 2 + Rails 4'
|
23
9
|
env:
|
24
|
-
SPEC_OPTS: '--require $PWD/spec/custom_formatter_for_rspec_2 --format CustomFormatterForRSpec2 --backtrace
|
10
|
+
SPEC_OPTS: '--require $PWD/spec/custom_formatter_for_rspec_2 --format CustomFormatterForRSpec2 --backtrace'
|
@@ -223,7 +223,7 @@ module RR
|
|
223
223
|
|
224
224
|
describe "#subject.method_name being called" do
|
225
225
|
it "returns the return value of the Double#returns block" do
|
226
|
-
double_definition_create.call(:foobar, 1, 2) {:baz}
|
226
|
+
double_definition_create.call(:foobar, [1, 2], {}) {:baz}
|
227
227
|
expect(subject.foobar(1, 2)).to eq :baz
|
228
228
|
end
|
229
229
|
end
|
@@ -254,7 +254,7 @@ module RR
|
|
254
254
|
original_method_called = true
|
255
255
|
end
|
256
256
|
end
|
257
|
-
double_definition_create.call(:foobar, 1, 2)
|
257
|
+
double_definition_create.call(:foobar, [1, 2], {})
|
258
258
|
subject.foobar(1, 2)
|
259
259
|
expect(original_method_called).to be_true
|
260
260
|
end
|
@@ -264,7 +264,7 @@ module RR
|
|
264
264
|
def subject.foobar(*args)
|
265
265
|
:baz;
|
266
266
|
end
|
267
|
-
double_definition_create.call(:foobar, 1, 2)
|
267
|
+
double_definition_create.call(:foobar, [1, 2], {})
|
268
268
|
expect(subject.foobar(1, 2)).to eq :baz
|
269
269
|
end
|
270
270
|
end
|
@@ -279,7 +279,7 @@ module RR
|
|
279
279
|
end
|
280
280
|
|
281
281
|
it "calls the block with the return value of the original method" do
|
282
|
-
double_definition_create.call(:foobar, 1, 2) do |value|
|
282
|
+
double_definition_create.call(:foobar, [1, 2], {}) do |value|
|
283
283
|
mock(value).a_method {99}
|
284
284
|
value
|
285
285
|
end
|
@@ -288,7 +288,7 @@ module RR
|
|
288
288
|
end
|
289
289
|
|
290
290
|
it "returns the return value of the block" do
|
291
|
-
double_definition_create.call(:foobar, 1, 2) do |value|
|
291
|
+
double_definition_create.call(:foobar, [1, 2], {}) do |value|
|
292
292
|
:something_else
|
293
293
|
end
|
294
294
|
expect(subject.foobar(1, 2)).to eq :something_else
|
@@ -306,7 +306,7 @@ module RR
|
|
306
306
|
|
307
307
|
context "when not passed a block" do
|
308
308
|
it "returns nil" do
|
309
|
-
double_definition_create.call(:foobar)
|
309
|
+
double_definition_create.call(:foobar, [], {})
|
310
310
|
expect(subject.foobar).to be_nil
|
311
311
|
end
|
312
312
|
end
|
@@ -314,7 +314,7 @@ module RR
|
|
314
314
|
context "when passed a block" do
|
315
315
|
describe "#subject.method_name being called" do
|
316
316
|
it "returns the return value of the block" do
|
317
|
-
double_definition_create.call(:foobar) {:baz}
|
317
|
+
double_definition_create.call(:foobar, [], {}) {:baz}
|
318
318
|
expect(subject.foobar).to eq :baz
|
319
319
|
end
|
320
320
|
end
|
@@ -323,7 +323,7 @@ module RR
|
|
323
323
|
context "when not passed args" do
|
324
324
|
describe "#subject.method_name being called with any arguments" do
|
325
325
|
it "invokes the implementation of the Stub" do
|
326
|
-
double_definition_create.call(:foobar) {:baz}
|
326
|
+
double_definition_create.call(:foobar, [], {}) {:baz}
|
327
327
|
expect(subject.foobar(1, 2)).to eq :baz
|
328
328
|
expect(subject.foobar()).to eq :baz
|
329
329
|
expect(subject.foobar([])).to eq :baz
|
@@ -334,14 +334,14 @@ module RR
|
|
334
334
|
context "when passed args" do
|
335
335
|
describe "#subject.method_name being called with the passed-in arguments" do
|
336
336
|
it "invokes the implementation of the Stub" do
|
337
|
-
double_definition_create.call(:foobar, 1, 2) {:baz}
|
337
|
+
double_definition_create.call(:foobar, [1, 2], {}) {:baz}
|
338
338
|
expect(subject.foobar(1, 2)).to eq :baz
|
339
339
|
end
|
340
340
|
end
|
341
341
|
|
342
342
|
describe "#subject.method_name being called with different arguments" do
|
343
343
|
it "raises a DoubleNotFoundError" do
|
344
|
-
double_definition_create.call(:foobar, 1, 2) {:baz}
|
344
|
+
double_definition_create.call(:foobar, [1, 2], {}) {:baz}
|
345
345
|
expect {
|
346
346
|
subject.foobar
|
347
347
|
}.to raise_error(RR::Errors::DoubleNotFoundError)
|
@@ -362,7 +362,7 @@ module RR
|
|
362
362
|
context "when not passed a block" do
|
363
363
|
describe "#subject.method_name being called" do
|
364
364
|
it "invokes the original implementanion" do
|
365
|
-
double_definition_create.call(:foobar)
|
365
|
+
double_definition_create.call(:foobar, [], {})
|
366
366
|
expect(subject.foobar).to eq :original_return_value
|
367
367
|
end
|
368
368
|
end
|
@@ -372,7 +372,7 @@ module RR
|
|
372
372
|
describe "#subject.method_name being called" do
|
373
373
|
it "invokes the original implementanion and invokes the block with the return value of the original implementanion" do
|
374
374
|
passed_in_value = nil
|
375
|
-
double_definition_create.call(:foobar) do |original_return_value|
|
375
|
+
double_definition_create.call(:foobar, [], {}) do |original_return_value|
|
376
376
|
passed_in_value = original_return_value
|
377
377
|
end
|
378
378
|
subject.foobar
|
@@ -380,7 +380,7 @@ module RR
|
|
380
380
|
end
|
381
381
|
|
382
382
|
it "returns the return value of the block" do
|
383
|
-
double_definition_create.call(:foobar) do |original_return_value|
|
383
|
+
double_definition_create.call(:foobar, [], {}) do |original_return_value|
|
384
384
|
:new_return_value
|
385
385
|
end
|
386
386
|
expect(subject.foobar).to eq :new_return_value
|
@@ -391,14 +391,14 @@ module RR
|
|
391
391
|
context "when passed args" do
|
392
392
|
describe "#subject.method_name being called with the passed-in arguments" do
|
393
393
|
it "invokes the implementation of the Stub" do
|
394
|
-
double_definition_create.call(:foobar, 1, 2) {:baz}
|
394
|
+
double_definition_create.call(:foobar, [1, 2], {}) {:baz}
|
395
395
|
expect(subject.foobar(1, 2)).to eq :baz
|
396
396
|
end
|
397
397
|
end
|
398
398
|
|
399
399
|
describe "#subject.method_name being called with different arguments" do
|
400
400
|
it "raises a DoubleNotFoundError" do
|
401
|
-
double_definition_create.call(:foobar, 1, 2) {:baz}
|
401
|
+
double_definition_create.call(:foobar, [1, 2], {}) {:baz}
|
402
402
|
expect {
|
403
403
|
subject.foobar
|
404
404
|
}.to raise_error(RR::Errors::DoubleNotFoundError)
|
@@ -416,7 +416,7 @@ module RR
|
|
416
416
|
context "when not passed args" do
|
417
417
|
describe "#subject.method_name being called with any arguments" do
|
418
418
|
it "raises a TimesCalledError" do
|
419
|
-
double_definition_create.call(:foobar)
|
419
|
+
double_definition_create.call(:foobar, [], {})
|
420
420
|
expect { subject.foobar }.to raise_error(RR::Errors::TimesCalledError)
|
421
421
|
expect { subject.foobar(1, 2) }.to raise_error(RR::Errors::TimesCalledError)
|
422
422
|
end
|
@@ -426,14 +426,14 @@ module RR
|
|
426
426
|
context "when passed args" do
|
427
427
|
describe "#subject.method_name being called with the passed-in arguments" do
|
428
428
|
it "raises a TimesCalledError" do
|
429
|
-
double_definition_create.call(:foobar, 1, 2)
|
429
|
+
double_definition_create.call(:foobar, [1, 2], {})
|
430
430
|
expect { subject.foobar(1, 2) }.to raise_error(RR::Errors::TimesCalledError)
|
431
431
|
end
|
432
432
|
end
|
433
433
|
|
434
434
|
describe "#subject.method_name being called with different arguments" do
|
435
435
|
it "raises a DoubleNotFoundError" do
|
436
|
-
double_definition_create.call(:foobar, 1, 2)
|
436
|
+
double_definition_create.call(:foobar, [1, 2], {})
|
437
437
|
expect { subject.foobar() }.to raise_error(RR::Errors::DoubleNotFoundError)
|
438
438
|
end
|
439
439
|
end
|
@@ -21,26 +21,26 @@ module RR
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "returns false when comparing with ArgumentEqualityExpectation" do
|
24
|
-
expect(expectation).to_not eq ArgumentEqualityExpectation.new(1)
|
24
|
+
expect(expectation).to_not eq ArgumentEqualityExpectation.new([1], {})
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "#exact_match?" do
|
29
29
|
it "returns false" do
|
30
|
-
expectation.should_not be_exact_match(1, 2, 3)
|
31
|
-
expectation.should_not be_exact_match(1, 2)
|
32
|
-
expectation.should_not be_exact_match(1)
|
33
|
-
expectation.should_not be_exact_match()
|
34
|
-
expectation.should_not be_exact_match("does not match")
|
30
|
+
expectation.should_not be_exact_match([1, 2, 3], {})
|
31
|
+
expectation.should_not be_exact_match([1, 2], {})
|
32
|
+
expectation.should_not be_exact_match([1], {})
|
33
|
+
expectation.should_not be_exact_match([], {})
|
34
|
+
expectation.should_not be_exact_match(["does not match"], {})
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "#wildcard_match?" do
|
39
39
|
it "returns true" do
|
40
40
|
expectation = AnyArgumentExpectation.new
|
41
|
-
expect(expectation).to be_wildcard_match(1, 2, 3)
|
42
|
-
expect(expectation).to be_wildcard_match("whatever")
|
43
|
-
expect(expectation).to be_wildcard_match("whatever", "else")
|
41
|
+
expect(expectation).to be_wildcard_match([1, 2, 3], {})
|
42
|
+
expect(expectation).to be_wildcard_match(["whatever"], {})
|
43
|
+
expect(expectation).to be_wildcard_match(["whatever", "else"], {})
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -5,7 +5,7 @@ module RR
|
|
5
5
|
describe ArgumentEqualityExpectation do
|
6
6
|
attr_reader :expectation
|
7
7
|
before do
|
8
|
-
@expectation = ArgumentEqualityExpectation.new(1, 2, 3)
|
8
|
+
@expectation = ArgumentEqualityExpectation.new([1, 2, 3], {})
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#expected_arguments" do
|
@@ -16,30 +16,30 @@ module RR
|
|
16
16
|
|
17
17
|
describe "==" do
|
18
18
|
it "returns true when passed in expected_arguments are equal" do
|
19
|
-
expect(expectation).to eq ArgumentEqualityExpectation.new(1, 2, 3)
|
19
|
+
expect(expectation).to eq ArgumentEqualityExpectation.new([1, 2, 3], {})
|
20
20
|
end
|
21
21
|
|
22
22
|
it "returns false when passed in expected_arguments are not equal" do
|
23
|
-
expect(expectation).to_not eq ArgumentEqualityExpectation.new(1, 2)
|
24
|
-
expect(expectation).to_not eq ArgumentEqualityExpectation.new(1)
|
25
|
-
expect(expectation).to_not eq ArgumentEqualityExpectation.new(:something)
|
26
|
-
expect(expectation).to_not eq ArgumentEqualityExpectation.new()
|
23
|
+
expect(expectation).to_not eq ArgumentEqualityExpectation.new([1, 2], {})
|
24
|
+
expect(expectation).to_not eq ArgumentEqualityExpectation.new([1], {})
|
25
|
+
expect(expectation).to_not eq ArgumentEqualityExpectation.new([:something], {})
|
26
|
+
expect(expectation).to_not eq ArgumentEqualityExpectation.new([], {})
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "#exact_match?" do
|
31
31
|
context "when all arguments exactly match" do
|
32
32
|
it "returns true" do
|
33
|
-
expect(expectation).to be_exact_match(1, 2, 3)
|
33
|
+
expect(expectation).to be_exact_match([1, 2, 3], {})
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
context "when all arguments do not exactly match" do
|
38
38
|
it "returns false" do
|
39
|
-
expectation.should_not be_exact_match(1, 2)
|
40
|
-
expectation.should_not be_exact_match(1)
|
41
|
-
expectation.should_not be_exact_match()
|
42
|
-
expectation.should_not be_exact_match("does not match")
|
39
|
+
expectation.should_not be_exact_match([1, 2], {})
|
40
|
+
expectation.should_not be_exact_match([1], {})
|
41
|
+
expectation.should_not be_exact_match([], {})
|
42
|
+
expectation.should_not be_exact_match(["does not match"], {})
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -47,26 +47,26 @@ module RR
|
|
47
47
|
describe "#wildcard_match?" do
|
48
48
|
context "when not an exact match" do
|
49
49
|
it "returns false" do
|
50
|
-
expectation = ArgumentEqualityExpectation.new(1)
|
51
|
-
expectation.should_not be_wildcard_match(1, 2, 3)
|
52
|
-
expectation.should_not be_wildcard_match("whatever")
|
53
|
-
expectation.should_not be_wildcard_match("whatever", "else")
|
50
|
+
expectation = ArgumentEqualityExpectation.new([1], {})
|
51
|
+
expectation.should_not be_wildcard_match([1, 2, 3], {})
|
52
|
+
expectation.should_not be_wildcard_match(["whatever"], {})
|
53
|
+
expectation.should_not be_wildcard_match(["whatever", "else"], {})
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
context "when an exact match" do
|
58
58
|
it "returns true" do
|
59
|
-
expectation = ArgumentEqualityExpectation.new(1, 2)
|
60
|
-
expect(expectation).to be_wildcard_match(1, 2)
|
61
|
-
expectation.should_not be_wildcard_match(1)
|
62
|
-
expectation.should_not be_wildcard_match("whatever", "else")
|
59
|
+
expectation = ArgumentEqualityExpectation.new([1, 2], {})
|
60
|
+
expect(expectation).to be_wildcard_match([1, 2], {})
|
61
|
+
expectation.should_not be_wildcard_match([1], {})
|
62
|
+
expectation.should_not be_wildcard_match(["whatever", "else"], {})
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
context "when not passed correct number of arguments" do
|
67
67
|
it "returns false" do
|
68
|
-
expectation.should_not be_wildcard_match()
|
69
|
-
expectation.should_not be_wildcard_match(Object.new, Object.new)
|
68
|
+
expectation.should_not be_wildcard_match([], {})
|
69
|
+
expectation.should_not be_wildcard_match([Object.new, Object.new], {})
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|