rr 1.0.5 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/CHANGES.md +24 -0
- data/LICENSE +2 -2
- data/README.md +124 -741
- data/VERSION +1 -1
- data/lib/rr.rb +2 -103
- data/lib/rr/adapters/minitest.rb +21 -13
- data/lib/rr/adapters/minitest_active_support.rb +34 -0
- data/lib/rr/adapters/none.rb +17 -0
- data/lib/rr/adapters/{rspec.rb → rspec/invocation_matcher.rb} +2 -27
- data/lib/rr/adapters/rspec_1.rb +42 -0
- data/lib/rr/adapters/rspec_2.rb +24 -0
- data/lib/rr/adapters/test_unit_1.rb +54 -0
- data/lib/rr/adapters/test_unit_2.rb +13 -0
- data/lib/rr/adapters/test_unit_2_active_support.rb +35 -0
- data/lib/rr/autohook.rb +43 -0
- data/lib/rr/core_ext/array.rb +12 -0
- data/lib/rr/core_ext/enumerable.rb +16 -0
- data/lib/rr/core_ext/hash.rb +20 -0
- data/lib/rr/core_ext/range.rb +8 -0
- data/lib/rr/core_ext/regexp.rb +8 -0
- data/lib/rr/double.rb +4 -4
- data/lib/rr/double_definitions/double_definition.rb +9 -3
- data/lib/rr/errors.rb +21 -0
- data/lib/rr/expectations/argument_equality_expectation.rb +10 -7
- data/lib/rr/expectations/times_called_expectation.rb +2 -8
- data/lib/rr/injections/double_injection.rb +1 -1
- data/lib/rr/method_dispatches/base_method_dispatch.rb +1 -1
- data/lib/rr/recorded_calls.rb +12 -12
- data/lib/rr/space.rb +5 -3
- data/lib/rr/times_called_matchers/never_matcher.rb +2 -2
- data/lib/rr/wildcard_matchers/anything.rb +2 -2
- data/lib/rr/wildcard_matchers/boolean.rb +3 -7
- data/lib/rr/wildcard_matchers/duck_type.rb +11 -15
- data/lib/rr/wildcard_matchers/hash_including.rb +14 -13
- data/lib/rr/wildcard_matchers/is_a.rb +6 -7
- data/lib/rr/wildcard_matchers/satisfy.rb +8 -8
- data/lib/rr/without_autohook.rb +112 -0
- data/rr.gemspec +28 -0
- data/spec/global_helper.rb +12 -0
- data/spec/suite.rb +93 -0
- data/spec/suites/common/adapter_tests.rb +37 -0
- data/spec/suites/common/rails_integration_test.rb +175 -0
- data/spec/suites/common/test_unit_tests.rb +25 -0
- data/spec/suites/minitest/integration/minitest_test.rb +13 -0
- data/spec/suites/minitest/test_helper.rb +3 -0
- data/spec/suites/rspec_1/integration/rspec_1_spec.rb +20 -0
- data/spec/suites/rspec_1/integration/test_unit_1_rails_spec.rb +19 -0
- data/spec/suites/rspec_1/integration/test_unit_2_rails_spec.rb +18 -0
- data/spec/suites/rspec_1/spec_helper.rb +24 -0
- data/spec/suites/rspec_2/functional/any_instance_of_spec.rb +47 -0
- data/spec/suites/rspec_2/functional/dont_allow_spec.rb +12 -0
- data/spec/suites/rspec_2/functional/dsl_spec.rb +13 -0
- data/spec/suites/rspec_2/functional/instance_of_spec.rb +14 -0
- data/spec/suites/rspec_2/functional/mock_spec.rb +241 -0
- data/spec/suites/rspec_2/functional/proxy_spec.rb +136 -0
- data/spec/suites/rspec_2/functional/spy_spec.rb +41 -0
- data/spec/suites/rspec_2/functional/strong_spec.rb +79 -0
- data/spec/suites/rspec_2/functional/stub_spec.rb +190 -0
- data/spec/suites/rspec_2/functional/wildcard_matchers_spec.rb +128 -0
- data/spec/suites/rspec_2/integration/minitest_rails_spec.rb +15 -0
- data/spec/suites/rspec_2/integration/rspec_2_spec.rb +20 -0
- data/spec/suites/rspec_2/integration/test_unit_rails_spec.rb +14 -0
- data/spec/suites/rspec_2/spec_helper.rb +27 -0
- data/spec/suites/rspec_2/support/matchers/wildcard_matcher_matchers.rb +32 -0
- data/spec/suites/rspec_2/support/shared_examples/space.rb +13 -0
- data/spec/suites/rspec_2/support/shared_examples/times_called_expectation.rb +9 -0
- data/spec/suites/rspec_2/unit/adapters/rr_methods/double_creators_spec.rb +135 -0
- data/spec/suites/rspec_2/unit/adapters/rr_methods/space_spec.rb +101 -0
- data/spec/suites/rspec_2/unit/adapters/rr_methods/wildcard_matchers_spec.rb +69 -0
- data/spec/suites/rspec_2/unit/adapters/rspec/invocation_matcher_spec.rb +297 -0
- data/spec/suites/rspec_2/unit/adapters/rspec_spec.rb +85 -0
- data/spec/suites/rspec_2/unit/core_ext/array_spec.rb +39 -0
- data/spec/suites/rspec_2/unit/core_ext/enumerable_spec.rb +81 -0
- data/spec/suites/rspec_2/unit/core_ext/hash_spec.rb +55 -0
- data/spec/suites/rspec_2/unit/core_ext/range_spec.rb +41 -0
- data/spec/suites/rspec_2/unit/core_ext/regexp_spec.rb +41 -0
- data/spec/suites/rspec_2/unit/double_definitions/child_double_definition_create_spec.rb +114 -0
- data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_blank_slate_spec.rb +93 -0
- data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_spec.rb +446 -0
- data/spec/suites/rspec_2/unit/errors/rr_error_spec.rb +67 -0
- data/spec/suites/rspec_2/unit/expectations/any_argument_expectation_spec.rb +48 -0
- data/spec/suites/rspec_2/unit/expectations/anything_argument_equality_expectation_spec.rb +14 -0
- data/spec/suites/rspec_2/unit/expectations/argument_equality_expectation_spec.rb +135 -0
- data/spec/suites/rspec_2/unit/expectations/boolean_argument_equality_expectation_spec.rb +30 -0
- data/spec/suites/rspec_2/unit/expectations/hash_including_argument_equality_expectation_spec.rb +82 -0
- data/spec/suites/rspec_2/unit/expectations/satisfy_argument_equality_expectation_spec.rb +61 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/any_times_matcher_spec.rb +22 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/at_least_matcher_spec.rb +37 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb +43 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/integer_matcher_spec.rb +58 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/proc_matcher_spec.rb +35 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/range_matcher_spec.rb +39 -0
- data/spec/suites/rspec_2/unit/hash_with_object_id_key_spec.rb +88 -0
- data/spec/suites/rspec_2/unit/injections/double_injection/double_injection_spec.rb +545 -0
- data/spec/suites/rspec_2/unit/injections/double_injection/double_injection_verify_spec.rb +32 -0
- data/spec/suites/rspec_2/unit/proc_from_block_spec.rb +14 -0
- data/spec/suites/rspec_2/unit/rr_spec.rb +28 -0
- data/spec/suites/rspec_2/unit/space_spec.rb +595 -0
- data/spec/suites/rspec_2/unit/spy_verification_spec.rb +133 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/any_times_matcher_spec.rb +46 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/at_least_matcher_spec.rb +54 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/at_most_matcher_spec.rb +69 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/integer_matcher_spec.rb +69 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/proc_matcher_spec.rb +54 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/range_matcher_spec.rb +75 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/times_called_matcher_spec.rb +117 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/anything_spec.rb +33 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/boolean_spec.rb +45 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/duck_type_spec.rb +64 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/hash_including_spec.rb +64 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/is_a_spec.rb +55 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/numeric_spec.rb +46 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/satisfy_spec.rb +57 -0
- data/spec/suites/test_unit_1/integration/test_unit_1_test.rb +6 -0
- data/spec/suites/test_unit_1/test_helper.rb +7 -0
- data/spec/suites/test_unit_2/integration/test_unit_2_test.rb +6 -0
- data/spec/suites/test_unit_2/test_helper.rb +3 -0
- metadata +183 -19
- data/Gemfile +0 -9
- data/Rakefile +0 -34
- data/lib/rr/adapters/rspec2.rb +0 -30
- data/lib/rr/adapters/test_unit.rb +0 -33
- data/lib/rr/errors/argument_equality_error.rb +0 -6
- data/lib/rr/wildcard_matchers/range.rb +0 -7
- data/lib/rr/wildcard_matchers/regexp.rb +0 -7
- data/spec/runner.rb +0 -41
@@ -0,0 +1,12 @@
|
|
1
|
+
class Array
|
2
|
+
def wildcard_match?(other)
|
3
|
+
return false unless other.is_a?(Array)
|
4
|
+
each_with_index do |value, i|
|
5
|
+
if value.respond_to?(:wildcard_match?)
|
6
|
+
return false unless value.wildcard_match?(other[i])
|
7
|
+
else
|
8
|
+
return false unless value == other[i]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Enumerable
|
2
|
+
def wildcard_match?(other)
|
3
|
+
if is_a?(String)
|
4
|
+
return RR::Expectations::ArgumentEqualityExpectation.recursive_safe_eq(self, other)
|
5
|
+
end
|
6
|
+
return false unless other.is_a?(Enumerable)
|
7
|
+
other_entries = other.entries
|
8
|
+
each_with_index do |value, i|
|
9
|
+
if value.respond_to?(:wildcard_match?)
|
10
|
+
return false unless value.wildcard_match?(other_entries[i])
|
11
|
+
else
|
12
|
+
return false unless value == other_entries[i]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Hash
|
2
|
+
def wildcard_match?(other)
|
3
|
+
return false unless other.is_a?(Hash)
|
4
|
+
|
5
|
+
other_keys = other.keys
|
6
|
+
other_values = other.values
|
7
|
+
each_with_index do |(key, value), i|
|
8
|
+
if key.respond_to?(:wildcard_match?)
|
9
|
+
return false unless key.wildcard_match?(other_keys[i])
|
10
|
+
else
|
11
|
+
return false unless key == other_keys[i]
|
12
|
+
end
|
13
|
+
if value.respond_to?(:wildcard_match?)
|
14
|
+
return false unless value.wildcard_match?(other_values[i])
|
15
|
+
else
|
16
|
+
return false unless value == other_values[i]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/rr/double.rb
CHANGED
@@ -106,21 +106,21 @@ module RR
|
|
106
106
|
|
107
107
|
def verify_times_matcher_is_set
|
108
108
|
unless definition.times_matcher
|
109
|
-
raise RR::Errors
|
109
|
+
raise RR::Errors.build_error(:DoubleDefinitionError, "#definition.times_matcher is not set")
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
113
|
def verify_argument_expectation_is_set
|
114
114
|
unless definition.argument_expectation
|
115
|
-
raise RR::Errors
|
115
|
+
raise RR::Errors.build_error(:DoubleDefinitionError, "#definition.argument_expectation is not set")
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
119
|
def verify_method_signature
|
120
120
|
unless double_injection.subject_has_original_method?
|
121
|
-
raise RR::Errors
|
121
|
+
raise RR::Errors.build_error(:SubjectDoesNotImplementMethodError)
|
122
122
|
end
|
123
|
-
raise RR::Errors
|
123
|
+
raise RR::Errors.build_error(:SubjectHasDifferentArityError) unless arity_matches?
|
124
124
|
end
|
125
125
|
|
126
126
|
def subject_arity
|
@@ -299,17 +299,23 @@ module RR
|
|
299
299
|
end
|
300
300
|
|
301
301
|
def exact_match?(*arguments)
|
302
|
-
|
302
|
+
unless @argument_expectation
|
303
|
+
raise RR::Errors.build_error(:DoubleDefinitionError, "#argument_expectation must be defined on #{inspect}")
|
304
|
+
end
|
303
305
|
@argument_expectation.exact_match?(*arguments)
|
304
306
|
end
|
305
307
|
|
306
308
|
def wildcard_match?(*arguments)
|
307
|
-
|
309
|
+
unless @argument_expectation
|
310
|
+
raise RR::Errors.build_error(:DoubleDefinitionError, "#argument_expectation must be defined on #{inspect}")
|
311
|
+
end
|
308
312
|
@argument_expectation.wildcard_match?(*arguments)
|
309
313
|
end
|
310
314
|
|
311
315
|
def terminal?
|
312
|
-
|
316
|
+
unless @times_matcher
|
317
|
+
raise RR::Errors.build_error(:DoubleDefinitionError, "#argument_expectation must be defined on #{inspect}")
|
318
|
+
end
|
313
319
|
@times_matcher.terminal?
|
314
320
|
end
|
315
321
|
|
data/lib/rr/errors.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module RR
|
2
|
+
class << self
|
3
|
+
attr_accessor :overridden_error_class
|
4
|
+
end
|
5
|
+
|
6
|
+
module Errors
|
7
|
+
def self.build_error(given_error, message = nil, backtrace = nil)
|
8
|
+
error_class = self.error_class(given_error)
|
9
|
+
error = message ? error_class.new(message) : error_class.new
|
10
|
+
error.backtrace = backtrace if error_class < RR::Errors::RRError
|
11
|
+
error
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.error_class(given_error)
|
15
|
+
RR.overridden_error_class ||
|
16
|
+
(given_error.is_a?(Symbol) ?
|
17
|
+
RR::Errors.const_get(given_error) :
|
18
|
+
given_error)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,6 +1,14 @@
|
|
1
1
|
module RR
|
2
2
|
module Expectations
|
3
3
|
class ArgumentEqualityExpectation #:nodoc:
|
4
|
+
def self.recursive_safe_eq(arg1, arg2)
|
5
|
+
if arg1.respond_to?(:'__rr__original_==')
|
6
|
+
arg1.__send__(:'__rr__original_==', arg2)
|
7
|
+
else
|
8
|
+
arg1 == arg2
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
attr_reader :expected_arguments
|
5
13
|
|
6
14
|
def initialize(*expected_arguments)
|
@@ -10,7 +18,7 @@ module RR
|
|
10
18
|
def exact_match?(*arguments)
|
11
19
|
return false unless arguments.length == expected_arguments.length
|
12
20
|
arguments.each_with_index do |arg, index|
|
13
|
-
return false unless
|
21
|
+
return false unless self.class.recursive_safe_eq(expected_arguments[index], arg)
|
14
22
|
end
|
15
23
|
true
|
16
24
|
end
|
@@ -22,7 +30,7 @@ module RR
|
|
22
30
|
if expected_argument.respond_to?(:wildcard_match?)
|
23
31
|
return false unless expected_argument.wildcard_match?(arg)
|
24
32
|
else
|
25
|
-
return false unless
|
33
|
+
return false unless self.class.recursive_safe_eq(expected_argument, arg)
|
26
34
|
end
|
27
35
|
end
|
28
36
|
true
|
@@ -31,11 +39,6 @@ module RR
|
|
31
39
|
def ==(other)
|
32
40
|
expected_arguments == other.expected_arguments
|
33
41
|
end
|
34
|
-
|
35
|
-
protected
|
36
|
-
def equality_match(arg1, arg2)
|
37
|
-
arg1.respond_to?(:'__rr__original_==') ? arg1.__send__(:'__rr__original_==', arg2) : arg1 == arg2
|
38
|
-
end
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
@@ -26,13 +26,7 @@ module RR
|
|
26
26
|
|
27
27
|
def verify!
|
28
28
|
unless verify
|
29
|
-
|
30
|
-
error = Errors::TimesCalledError.new(error_message)
|
31
|
-
error.backtrace = @verify_backtrace
|
32
|
-
raise error
|
33
|
-
else
|
34
|
-
raise Errors::TimesCalledError, error_message
|
35
|
-
end
|
29
|
+
raise RR::Errors.build_error(:TimesCalledError, error_message, @verify_backtrace)
|
36
30
|
end
|
37
31
|
end
|
38
32
|
|
@@ -46,7 +40,7 @@ module RR
|
|
46
40
|
end
|
47
41
|
|
48
42
|
def verify_input_error
|
49
|
-
raise Errors
|
43
|
+
raise RR::Errors.build_error(:TimesCalledError, error_message)
|
50
44
|
end
|
51
45
|
|
52
46
|
def error_message
|
@@ -145,7 +145,7 @@ module RR
|
|
145
145
|
def #{method_name}(*args, &block)
|
146
146
|
arguments = MethodArguments.new(args, block)
|
147
147
|
obj = ::RR::Injections::DoubleInjection::BoundObjects[#{id}]
|
148
|
-
RR::Injections::DoubleInjection.dispatch_method(self, obj, :#{method_name}, arguments.arguments, arguments.block)
|
148
|
+
::RR::Injections::DoubleInjection.dispatch_method(self, obj, :#{method_name}, arguments.arguments, arguments.block)
|
149
149
|
end
|
150
150
|
RUBY
|
151
151
|
self
|
@@ -73,7 +73,7 @@ module RR
|
|
73
73
|
" #{Double.formatted_name(method_name, args)}\n" <<
|
74
74
|
"expected invocations:\n" <<
|
75
75
|
Double.list_message_part(doubles)
|
76
|
-
raise Errors
|
76
|
+
raise RR::Errors.build_error(:DoubleNotFoundError, message)
|
77
77
|
end
|
78
78
|
|
79
79
|
def_delegators :definition, :after_call_proc
|
data/lib/rr/recorded_calls.rb
CHANGED
@@ -6,26 +6,26 @@ module RR
|
|
6
6
|
@recorded_calls = recorded_calls
|
7
7
|
@ordered_index = 0
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
attr_reader :recorded_calls
|
11
|
-
|
11
|
+
|
12
12
|
def clear
|
13
13
|
self.ordered_index = 0
|
14
14
|
recorded_calls.clear
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def <<(recorded_call)
|
18
18
|
recorded_calls << recorded_call
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def any?(&block)
|
22
22
|
recorded_calls.any?(&block)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def ==(other)
|
26
26
|
recorded_calls == other.recorded_calls
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def match_error(spy_verification)
|
30
30
|
double_injection_exists_error(spy_verification) || begin
|
31
31
|
if spy_verification.ordered?
|
@@ -35,20 +35,20 @@ module RR
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
protected
|
40
40
|
attr_accessor :ordered_index
|
41
41
|
|
42
42
|
def double_injection_exists_error(spy_verification)
|
43
43
|
unless Injections::DoubleInjection.exists_by_subject?(spy_verification.subject, spy_verification.method_name)
|
44
|
-
RR::Errors::SpyVerificationErrors::DoubleInjectionNotFoundError
|
44
|
+
RR::Errors.build_error(RR::Errors::SpyVerificationErrors::DoubleInjectionNotFoundError,
|
45
45
|
"A Double Injection for the subject and method call:\n" <<
|
46
46
|
"#{spy_verification.subject.inspect}\n" <<
|
47
47
|
"#{spy_verification.method_name}\ndoes not exist in:\n" <<
|
48
48
|
"\t#{recorded_calls.map {|call| call.inspect}.join("\n\t")}"
|
49
49
|
)
|
50
50
|
end
|
51
|
-
end
|
51
|
+
end
|
52
52
|
|
53
53
|
def ordered_match_error(spy_verification)
|
54
54
|
memoized_matching_recorded_calls = matching_recorded_calls(spy_verification)
|
@@ -63,7 +63,7 @@ module RR
|
|
63
63
|
|
64
64
|
def unordered_match_error(spy_verification)
|
65
65
|
memoized_matching_recorded_calls = matching_recorded_calls(spy_verification)
|
66
|
-
|
66
|
+
|
67
67
|
spy_verification.times_matcher.matches?(
|
68
68
|
memoized_matching_recorded_calls.size
|
69
69
|
) ? nil : invocation_count_error(spy_verification, memoized_matching_recorded_calls)
|
@@ -90,7 +90,7 @@ module RR
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def invocation_count_error(spy_verification, matching_recorded_calls)
|
93
|
-
RR::Errors::SpyVerificationErrors::InvocationCountError
|
93
|
+
RR::Errors.build_error(RR::Errors::SpyVerificationErrors::InvocationCountError,
|
94
94
|
"On subject #{spy_verification.subject.inspect}\n" <<
|
95
95
|
"Expected #{Double.formatted_name(spy_verification.method_name, spy_verification.argument_expectation.expected_arguments)}\n" <<
|
96
96
|
"to be called #{spy_verification.times_matcher.expected_times_message},\n" <<
|
@@ -100,4 +100,4 @@ module RR
|
|
100
100
|
)
|
101
101
|
end
|
102
102
|
end
|
103
|
-
end
|
103
|
+
end
|
data/lib/rr/space.rb
CHANGED
@@ -37,14 +37,14 @@ module RR
|
|
37
37
|
# in the correct position.
|
38
38
|
def verify_ordered_double(double)
|
39
39
|
unless double.terminal?
|
40
|
-
raise Errors
|
41
|
-
|
40
|
+
raise RR::Errors.build_error(:DoubleOrderError,
|
41
|
+
"Ordered Doubles cannot have a NonTerminal TimesCalledExpectation")
|
42
42
|
end
|
43
43
|
unless @ordered_doubles.first == double
|
44
44
|
message = Double.formatted_name(double.method_name, double.expected_arguments)
|
45
45
|
message << " called out of order in list\n"
|
46
46
|
message << Double.list_message_part(@ordered_doubles)
|
47
|
-
raise Errors
|
47
|
+
raise RR::Errors.build_error(:DoubleOrderError, message)
|
48
48
|
end
|
49
49
|
@ordered_doubles.shift unless double.attempt?
|
50
50
|
double
|
@@ -59,6 +59,8 @@ module RR
|
|
59
59
|
|
60
60
|
# Resets the registered Doubles and ordered Doubles
|
61
61
|
def reset
|
62
|
+
RR.trim_backtrace = false
|
63
|
+
RR.overridden_error_class = nil
|
62
64
|
reset_ordered_doubles
|
63
65
|
Injections::DoubleInjection.reset
|
64
66
|
reset_method_missing_injections
|
@@ -2,22 +2,18 @@ module RR
|
|
2
2
|
module WildcardMatchers
|
3
3
|
class Boolean
|
4
4
|
def wildcard_match?(other)
|
5
|
-
self == other ||
|
5
|
+
self == other ||
|
6
|
+
other.equal?(true) || other.equal?(false)
|
6
7
|
end
|
7
8
|
|
8
9
|
def ==(other)
|
9
10
|
other.is_a?(self.class)
|
10
11
|
end
|
11
|
-
|
12
|
+
alias :eql? :==
|
12
13
|
|
13
14
|
def inspect
|
14
15
|
'boolean'
|
15
16
|
end
|
16
|
-
|
17
|
-
protected
|
18
|
-
def is_a_boolean?(subject)
|
19
|
-
subject.is_a?(TrueClass) || subject.is_a?(FalseClass)
|
20
|
-
end
|
21
17
|
end
|
22
18
|
end
|
23
19
|
end
|
@@ -8,25 +8,21 @@ module RR
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def wildcard_match?(other)
|
11
|
-
|
12
|
-
required_methods.
|
13
|
-
return false unless other.respond_to?(m)
|
14
|
-
end
|
15
|
-
return true
|
11
|
+
self == other ||
|
12
|
+
required_methods.all? {|m| other.respond_to?(m) }
|
16
13
|
end
|
17
14
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
end.join(', ')
|
22
|
-
"duck_type(#{formatted_required_methods})"
|
15
|
+
def ==(other)
|
16
|
+
other.is_a?(self.class) &&
|
17
|
+
other.required_methods == self.required_methods
|
23
18
|
end
|
19
|
+
alias :eql? :==
|
24
20
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
21
|
+
def inspect
|
22
|
+
formatted_required_methods =
|
23
|
+
required_methods.map { |method_name| method_name.inspect }.join(', ')
|
24
|
+
"duck_type(#{formatted_required_methods})"
|
28
25
|
end
|
29
|
-
alias_method :eql?, :==
|
30
26
|
end
|
31
27
|
end
|
32
|
-
end
|
28
|
+
end
|
@@ -4,26 +4,27 @@ module RR
|
|
4
4
|
attr_reader :expected_hash
|
5
5
|
|
6
6
|
def initialize(expected_hash)
|
7
|
-
@expected_hash = expected_hash.
|
7
|
+
@expected_hash = expected_hash.dup
|
8
8
|
end
|
9
9
|
|
10
10
|
def wildcard_match?(other)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
self == other || (
|
12
|
+
other.is_a?(Hash) &&
|
13
|
+
expected_hash.all? { |k, v|
|
14
|
+
other.key?(k) && other[k] == expected_hash[k]
|
15
|
+
}
|
16
|
+
)
|
16
17
|
end
|
17
18
|
|
18
|
-
def
|
19
|
-
|
19
|
+
def ==(other)
|
20
|
+
other.is_a?(self.class) &&
|
21
|
+
other.expected_hash == self.expected_hash
|
20
22
|
end
|
23
|
+
alias :eql? :==
|
21
24
|
|
22
|
-
def
|
23
|
-
|
24
|
-
self.expected_hash == other.expected_hash
|
25
|
+
def inspect
|
26
|
+
"hash_including(#{expected_hash.inspect})"
|
25
27
|
end
|
26
|
-
alias_method :eql?, :==
|
27
28
|
end
|
28
29
|
end
|
29
|
-
end
|
30
|
+
end
|