rr 1.1.2.rc1 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Appraisals +3 -43
- data/CHANGES.md +98 -6
- data/CREDITS.md +5 -0
- data/Gemfile +1 -17
- data/README.md +29 -32
- data/Rakefile +42 -40
- data/doc/02_syntax_comparison.md +1 -0
- data/lib/rr/class_instance_method_defined.rb +1 -1
- data/lib/rr/core_ext/array.rb +2 -0
- data/lib/rr/core_ext/hash.rb +2 -0
- data/lib/rr/deprecations.rb +97 -0
- 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/double_injections/any_instance_of.rb +1 -1
- data/lib/rr/double_definitions/double_injections/instance.rb +2 -2
- 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/dsl.rb +152 -0
- 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 +67 -19
- data/lib/rr/injections/method_missing_injection.rb +37 -6
- data/lib/rr/integrations/minitest_4.rb +1 -1
- data/lib/rr/integrations/minitest_4_active_support.rb +1 -1
- data/lib/rr/integrations/rspec/invocation_matcher.rb +0 -8
- data/lib/rr/integrations/rspec_2.rb +28 -8
- 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 +35 -0
- data/lib/rr/recorded_calls.rb +23 -9
- data/lib/rr/space.rb +15 -5
- data/lib/rr/spy_verification.rb +13 -5
- data/lib/rr/version.rb +1 -1
- data/lib/rr/wildcard_matchers.rb +10 -10
- data/lib/rr/without_autohook.rb +7 -14
- data/rr.gemspec +8 -3
- data/spec/defines_spec_suite_tasks.rb +12 -0
- data/spec/global_helper.rb +5 -0
- data/spec/spec_suite_configuration.rb +1 -7
- data/spec/suites.yml +0 -14
- data/spec/suites/rspec_2/functional/any_instance_of_spec.rb +133 -33
- data/spec/suites/rspec_2/functional/dont_allow_spec.rb +13 -8
- data/spec/suites/rspec_2/functional/mock_bang_spec.rb +20 -0
- data/spec/suites/rspec_2/functional/mock_instance_of_spec.rb +14 -0
- data/spec/suites/rspec_2/functional/mock_instance_of_strong_spec.rb +15 -0
- data/spec/suites/rspec_2/functional/mock_proxy_instance_of_spec.rb +15 -0
- data/spec/suites/rspec_2/functional/mock_proxy_spec.rb +14 -0
- data/spec/suites/rspec_2/functional/mock_spec.rb +8 -232
- data/spec/suites/rspec_2/functional/mock_strong_spec.rb +14 -0
- data/spec/suites/rspec_2/functional/received_spec.rb +16 -0
- data/spec/suites/rspec_2/functional/spy_spec.rb +89 -28
- data/spec/suites/rspec_2/functional/stub_bang_spec.rb +20 -0
- data/spec/suites/rspec_2/functional/stub_instance_of_spec.rb +15 -0
- data/spec/suites/rspec_2/functional/stub_instance_of_strong_spec.rb +15 -0
- data/spec/suites/rspec_2/functional/stub_proxy_instance_of_spec.rb +16 -0
- data/spec/suites/rspec_2/functional/stub_proxy_spec.rb +45 -0
- data/spec/suites/rspec_2/functional/stub_spec.rb +42 -161
- data/spec/suites/rspec_2/functional/stub_strong_spec.rb +15 -0
- data/spec/suites/rspec_2/helper.rb +2 -2
- data/spec/suites/rspec_2/support/mixins/double_definition_creator_helpers.rb +173 -0
- data/spec/suites/rspec_2/support/mixins/mock_definition_creator_helpers.rb +45 -0
- data/spec/suites/rspec_2/support/mixins/proxy_definition_creator_helpers.rb +33 -0
- data/spec/suites/rspec_2/support/mixins/stub_creator_helpers.rb +43 -0
- data/spec/suites/rspec_2/support/mixins/stub_definition_creator_helpers.rb +45 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/argument_expectations_with_never_called_qualifier.rb +39 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/argument_expectations_with_times_called_qualifier.rb +50 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/argument_expectations_without_qualifiers.rb +131 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/dont_allow.rb +148 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_instance_of.rb +26 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_instance_of_strong.rb +28 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_proxy.rb +11 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_strong.rb +37 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mocking.rb +107 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_instance_of.rb +32 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_instance_of_strong.rb +39 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_proxy.rb +11 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_strong.rb +37 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stubbing.rb +57 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/array_flatten_bug.rb +35 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/block_form.rb +31 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/comparing_arity.rb +63 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/object_is_proxy.rb +43 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/sequential_invocations.rb +26 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/setting_implementation.rb +51 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/yields.rb +81 -0
- data/spec/suites/rspec_2/unit/core_ext/enumerable_spec.rb +0 -28
- data/spec/suites/rspec_2/unit/deprecations_spec.rb +27 -0
- data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_spec.rb +18 -18
- data/spec/suites/rspec_2/unit/dsl/double_creators_spec.rb +133 -0
- data/spec/suites/rspec_2/unit/dsl/space_spec.rb +99 -0
- data/spec/suites/rspec_2/unit/dsl/wildcard_matchers_spec.rb +67 -0
- 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/injections/double_injection/double_injection_spec.rb +0 -12
- data/spec/suites/rspec_2/unit/integrations/rspec_spec.rb +4 -19
- data/spec/suites/rspec_2/unit/space_spec.rb +7 -4
- data/spec/suites/rspec_2/unit/spy_verification_spec.rb +1 -1
- data/spec/support/adapter.rb +1 -1
- data/spec/support/adapter_tests/rspec.rb +19 -15
- data/spec/support/project/generator.rb +0 -4
- metadata +113 -58
- data/gemfiles/ruby_18_rspec_1.gemfile +0 -14
- data/gemfiles/ruby_18_rspec_1.gemfile.lock +0 -38
- data/gemfiles/ruby_18_rspec_1_rails_2.gemfile +0 -18
- data/gemfiles/ruby_18_rspec_1_rails_2.gemfile.lock +0 -64
- data/gemfiles/ruby_19_rspec_2_rails_3.gemfile +0 -15
- data/gemfiles/ruby_19_rspec_2_rails_3.gemfile.lock +0 -123
- data/lib/rr/adapters.rb +0 -34
- data/lib/rr/adapters/rr_methods.rb +0 -142
- data/lib/rr/integrations/rspec_1.rb +0 -46
- data/lib/rr/integrations/test_unit_1.rb +0 -63
- data/lib/rr/integrations/test_unit_2.rb +0 -17
- data/lib/rr/integrations/test_unit_200.rb +0 -27
- data/lib/rr/integrations/test_unit_200_active_support.rb +0 -25
- data/lib/rr/integrations/test_unit_2_active_support.rb +0 -38
- data/lib/rr/proc_from_block.rb +0 -11
- data/spec/suites/rspec_1/helper.rb +0 -24
- data/spec/suites/rspec_1/integration/rspec_1_spec.rb +0 -93
- data/spec/suites/rspec_1/integration/test_unit_1_spec.rb +0 -102
- data/spec/suites/rspec_1/integration/test_unit_2_spec.rb +0 -109
- data/spec/suites/rspec_1/spec_helper.rb +0 -3
- data/spec/suites/rspec_1_rails_2/integration/astc_rails_2_spec.rb +0 -141
- data/spec/suites/rspec_1_rails_2/integration/rspec_1_rails_2_spec.rb +0 -132
- data/spec/suites/rspec_1_rails_2/integration/test_unit_1_rails_2_spec.rb +0 -141
- data/spec/suites/rspec_1_rails_2/integration/test_unit_2_rails_2_spec.rb +0 -148
- data/spec/suites/rspec_1_rails_2/spec_helper.rb +0 -3
- data/spec/suites/rspec_2/functional/dsl_spec.rb +0 -13
- data/spec/suites/rspec_2/functional/instance_of_spec.rb +0 -14
- data/spec/suites/rspec_2/functional/proxy_spec.rb +0 -136
- data/spec/suites/rspec_2/functional/strong_spec.rb +0 -79
- data/spec/suites/rspec_2/integration/rspec_2_spec.rb +0 -133
- data/spec/suites/rspec_2/integration/test_unit_200_spec.rb +0 -102
- data/spec/suites/rspec_2/integration/test_unit_2_spec.rb +0 -109
- data/spec/suites/rspec_2/unit/adapters/rr_methods/double_creators_spec.rb +0 -135
- data/spec/suites/rspec_2/unit/adapters/rr_methods/space_spec.rb +0 -101
- data/spec/suites/rspec_2/unit/adapters/rr_methods/wildcard_matchers_spec.rb +0 -69
- data/spec/suites/rspec_2/unit/proc_from_block_spec.rb +0 -14
- data/spec/suites/rspec_2_rails_3/integration/astc_rails_3_spec.rb +0 -141
- data/spec/suites/rspec_2_rails_3/integration/minitest_4_rails_3_spec.rb +0 -148
- data/spec/suites/rspec_2_rails_3/integration/rspec_2_rails_3_spec.rb +0 -172
- data/spec/suites/rspec_2_rails_3/integration/test_unit_200_rails_3_spec.rb +0 -141
- data/spec/suites/rspec_2_rails_3/integration/test_unit_2_rails_3_spec.rb +0 -148
- data/spec/suites/rspec_2_rails_3/spec_helper.rb +0 -3
- 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/integration/rspec_2_rails_4_spec.rb +0 -173
- data/spec/suites/rspec_2_rails_4/integration/test_unit_200_rails_4_spec.rb +0 -142
- data/spec/suites/rspec_2_rails_4/integration/test_unit_2_rails_4_spec.rb +0 -149
- data/spec/suites/rspec_2_rails_4/spec_helper.rb +0 -3
@@ -9,8 +9,13 @@ module RR
|
|
9
9
|
|
10
10
|
attr_reader :subject, :subject_class, :method_name
|
11
11
|
|
12
|
-
def initialize(subject, subject_class, method_name, args, block)
|
13
|
-
@subject
|
12
|
+
def initialize(subject, subject_class, method_name, args, kwargs, block)
|
13
|
+
@subject = subject
|
14
|
+
@subject_class = subject_class
|
15
|
+
@method_name = method_name
|
16
|
+
@args = args
|
17
|
+
@kwargs = kwargs
|
18
|
+
@block = block
|
14
19
|
end
|
15
20
|
|
16
21
|
def call
|
@@ -40,14 +45,18 @@ module RR
|
|
40
45
|
protected
|
41
46
|
def call_implementation
|
42
47
|
if implementation_is_original_method?
|
43
|
-
space.record_call(subject, method_name, args, block)
|
44
|
-
double.method_call(args)
|
48
|
+
space.record_call(subject, method_name, args, kwargs, block)
|
49
|
+
double.method_call(args, kwargs)
|
45
50
|
call_original_method
|
46
51
|
else
|
47
52
|
if double_injection = Injections::DoubleInjection.find(subject_class, method_name)
|
48
53
|
double_injection.bind_method
|
49
54
|
# The DoubleInjection takes care of calling double.method_call
|
50
|
-
|
55
|
+
if KeywordArguments.fully_supported?
|
56
|
+
subject.__send__(method_name, *args, **kwargs, &block)
|
57
|
+
else
|
58
|
+
subject.__send__(method_name, *args, &block)
|
59
|
+
end
|
51
60
|
else
|
52
61
|
nil
|
53
62
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RR
|
2
|
+
class RecordedCall < Struct.new(:subject,
|
3
|
+
:method_name,
|
4
|
+
:arguments,
|
5
|
+
:keyword_arguments,
|
6
|
+
:block)
|
7
|
+
def inspect
|
8
|
+
'[%s, %s, %s, %s, %s]' % [
|
9
|
+
subject_to_s,
|
10
|
+
method_name.inspect,
|
11
|
+
arguments.inspect,
|
12
|
+
keyword_arguments.inspect,
|
13
|
+
block.inspect
|
14
|
+
]
|
15
|
+
end
|
16
|
+
|
17
|
+
def ==(other)
|
18
|
+
other.is_a?(self.class) &&
|
19
|
+
subject == other.subject &&
|
20
|
+
method_name == other.method_name &&
|
21
|
+
arguments == other.arguments &&
|
22
|
+
keyword_arguments == other.keyword_arguments
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def subject_to_s
|
28
|
+
if subject.respond_to?(:__rr__original_to_s, true)
|
29
|
+
subject.__rr__original_to_s
|
30
|
+
else
|
31
|
+
subject.to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/rr/recorded_calls.rb
CHANGED
@@ -9,13 +9,21 @@ module RR
|
|
9
9
|
|
10
10
|
attr_reader :recorded_calls
|
11
11
|
|
12
|
+
def [](index)
|
13
|
+
@recorded_calls[index]
|
14
|
+
end
|
15
|
+
|
12
16
|
def clear
|
13
17
|
self.ordered_index = 0
|
14
18
|
recorded_calls.clear
|
15
19
|
end
|
16
20
|
|
17
|
-
def
|
18
|
-
recorded_calls <<
|
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)
|
19
27
|
end
|
20
28
|
|
21
29
|
def any?(&block)
|
@@ -43,9 +51,9 @@ module RR
|
|
43
51
|
unless Injections::DoubleInjection.exists_by_subject?(spy_verification.subject, spy_verification.method_name)
|
44
52
|
RR::Errors.build_error(RR::Errors::SpyVerificationErrors::DoubleInjectionNotFoundError,
|
45
53
|
"A Double Injection for the subject and method call:\n" <<
|
46
|
-
"#{spy_verification.
|
54
|
+
"#{spy_verification.subject_inspect}\n" <<
|
47
55
|
"#{spy_verification.method_name}\ndoes not exist in:\n" <<
|
48
|
-
"\t#{recorded_calls.map {|call| call.inspect}.join("\n\t")}"
|
56
|
+
"\t#{recorded_calls.map {|call| call.inspect }.join("\n\t")}"
|
49
57
|
)
|
50
58
|
end
|
51
59
|
end
|
@@ -77,22 +85,28 @@ module RR
|
|
77
85
|
|
78
86
|
def match_double_injection(spy_verification)
|
79
87
|
lambda do |recorded_call|
|
80
|
-
recorded_call
|
81
|
-
|
88
|
+
recorded_call.subject == spy_verification.subject &&
|
89
|
+
recorded_call.method_name == spy_verification.method_name
|
82
90
|
end
|
83
91
|
end
|
84
92
|
|
85
93
|
def match_argument_expectation(spy_verification)
|
86
94
|
lambda do |recorded_call|
|
87
|
-
spy_verification.argument_expectation
|
88
|
-
|
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)
|
89
100
|
end
|
90
101
|
end
|
91
102
|
|
92
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
|
93
107
|
RR::Errors.build_error(RR::Errors::SpyVerificationErrors::InvocationCountError,
|
94
108
|
"On subject #{spy_verification.subject.inspect}\n" <<
|
95
|
-
"Expected #{Double.formatted_name(
|
109
|
+
"Expected #{Double.formatted_name(method_name, arguments, keyword_arguments)}\n" <<
|
96
110
|
"to be called #{spy_verification.times_matcher.expected_times_message},\n" <<
|
97
111
|
"but was called #{matching_recorded_calls.size} times.\n" <<
|
98
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
|
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/spy_verification.rb
CHANGED
@@ -13,12 +13,12 @@ module RR
|
|
13
13
|
|
14
14
|
include RR::DoubleDefinitions::DoubleDefinition::TimesDefinitionConstructionMethods
|
15
15
|
include RR::DoubleDefinitions::DoubleDefinition::ArgumentDefinitionConstructionMethods
|
16
|
-
|
16
|
+
|
17
17
|
def ordered
|
18
18
|
@ordered = true
|
19
19
|
self
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def ordered?
|
23
23
|
@ordered
|
24
24
|
end
|
@@ -32,7 +32,15 @@ module RR
|
|
32
32
|
call
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
|
+
def subject_inspect
|
37
|
+
if subject.respond_to?(:__rr__original_inspect, true)
|
38
|
+
subject.__rr__original_inspect
|
39
|
+
else
|
40
|
+
subject.inspect
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
36
44
|
protected
|
37
45
|
attr_writer :times_matcher
|
38
46
|
|
@@ -40,9 +48,9 @@ module RR
|
|
40
48
|
# with_no_args and with actually set @argument_expectation
|
41
49
|
args.empty? ? with_no_args : with(*args)
|
42
50
|
end
|
43
|
-
|
51
|
+
|
44
52
|
def install_method_callback(return_value_block)
|
45
53
|
# Do nothing. This is to support DefinitionConstructionMethods
|
46
54
|
end
|
47
55
|
end
|
48
|
-
end
|
56
|
+
end
|
data/lib/rr/version.rb
CHANGED
data/lib/rr/wildcard_matchers.rb
CHANGED
@@ -12,7 +12,7 @@ divisible by a certain integer. In use, it might look like this:
|
|
12
12
|
|
13
13
|
mock(BananaGrabber).bunch_bananas(divisible_by(5))
|
14
14
|
|
15
|
-
To implement this, we need a class RR::WildcardMatchers::DivisibleBy with
|
15
|
+
To implement this, we need a class RR::WildcardMatchers::DivisibleBy with
|
16
16
|
these instance methods:
|
17
17
|
|
18
18
|
* ==(other)
|
@@ -38,7 +38,7 @@ might look like this:
|
|
38
38
|
DivisibleBy#==(other) should return true if other is a wildcard matcher that
|
39
39
|
matches the same things as self, so a natural way to write DivisibleBy#== is:
|
40
40
|
|
41
|
-
|
41
|
+
|
42
42
|
class RR::WildcardMatchers::DivisibleBy
|
43
43
|
def ==(other)
|
44
44
|
# Ensure that other is actually a DivisibleBy
|
@@ -86,7 +86,7 @@ false otherwise. In the case of DivisibleBy, wildcard_matches? reads:
|
|
86
86
|
# If other isn't a number, how can it be divisible by anything?
|
87
87
|
return false unless other.is_a?(Numeric)
|
88
88
|
|
89
|
-
# If other is in fact divisible by expected_divisor, then
|
89
|
+
# If other is in fact divisible by expected_divisor, then
|
90
90
|
# other modulo expected_divisor should be 0.
|
91
91
|
|
92
92
|
other % expected_divisor == 0
|
@@ -105,10 +105,10 @@ But that's less expressive than the original:
|
|
105
105
|
mock(BananaGrabber).bunch_bananas(divisible_by(5))
|
106
106
|
|
107
107
|
To be able to use the convenient divisible_by matcher rather than the uglier
|
108
|
-
DivisibleBy.new version, re-open the module RR::
|
109
|
-
|
108
|
+
DivisibleBy.new version, re-open the module RR::DSL and define divisible_by
|
109
|
+
there as a simple wrapper around DivisibleBy.new:
|
110
110
|
|
111
|
-
module RR::
|
111
|
+
module RR::DSL
|
112
112
|
def divisible_by(expected_divisor)
|
113
113
|
RR::WildcardMatchers::DivisibleBy.new(expected_divisor)
|
114
114
|
end
|
@@ -134,19 +134,19 @@ Here's all the code for DivisibleBy in one place for easy reference:
|
|
134
134
|
def inspect
|
135
135
|
"integer divisible by #{expected.divisor}"
|
136
136
|
end
|
137
|
-
|
137
|
+
|
138
138
|
def wildcard_matches?(other)
|
139
139
|
# If other isn't a number, how can it be divisible by anything?
|
140
140
|
return false unless other.is_a?(Numeric)
|
141
141
|
|
142
|
-
# If other is in fact divisible by expected_divisor, then
|
142
|
+
# If other is in fact divisible by expected_divisor, then
|
143
143
|
# other modulo expected_divisor should be 0.
|
144
144
|
|
145
145
|
other % expected_divisor == 0
|
146
146
|
end
|
147
147
|
end
|
148
|
-
|
149
|
-
module RR::
|
148
|
+
|
149
|
+
module RR::DSL
|
150
150
|
def divisible_by(expected_divisor)
|
151
151
|
RR::WildcardMatchers::DivisibleBy.new(expected_divisor)
|
152
152
|
end
|
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
|
|
@@ -36,7 +38,7 @@ require 'rr/double_definitions/strategies/implementation/proxy'
|
|
36
38
|
require 'rr/double_definitions/strategies/double_injection/double_injection_strategy'
|
37
39
|
require 'rr/double_definitions/strategies/double_injection/instance'
|
38
40
|
require 'rr/double_definitions/strategies/double_injection/any_instance_of'
|
39
|
-
require 'rr/
|
41
|
+
require 'rr/dsl'
|
40
42
|
require 'rr/double_definitions/double_injections/instance'
|
41
43
|
require 'rr/double_definitions/double_injections/any_instance_of'
|
42
44
|
require 'rr/double_definitions/double_definition'
|
@@ -49,8 +51,8 @@ require 'rr/method_dispatches/base_method_dispatch'
|
|
49
51
|
require 'rr/method_dispatches/method_dispatch'
|
50
52
|
require 'rr/method_dispatches/method_missing_dispatch'
|
51
53
|
require 'rr/hash_with_object_id_key'
|
54
|
+
require 'rr/recorded_call'
|
52
55
|
require 'rr/recorded_calls'
|
53
|
-
require 'rr/proc_from_block'
|
54
56
|
|
55
57
|
require 'rr/double_definitions/double_definition_create_blank_slate'
|
56
58
|
require 'rr/double_definitions/double_definition_create'
|
@@ -88,24 +90,19 @@ require 'rr/spy_verification'
|
|
88
90
|
require 'rr/integrations'
|
89
91
|
require 'rr/integrations/decorator'
|
90
92
|
require 'rr/integrations/rspec/invocation_matcher'
|
91
|
-
require 'rr/integrations/rspec_1'
|
92
93
|
require 'rr/integrations/rspec_2'
|
93
94
|
require 'rr/integrations/minitest_4'
|
94
95
|
require 'rr/integrations/minitest_4_active_support'
|
95
96
|
require 'rr/integrations/minitest'
|
96
97
|
require 'rr/integrations/minitest_active_support'
|
97
|
-
|
98
|
-
require 'rr/
|
99
|
-
require 'rr/integrations/test_unit_200_active_support'
|
100
|
-
require 'rr/integrations/test_unit_2'
|
101
|
-
require 'rr/integrations/test_unit_2_active_support'
|
102
|
-
require 'rr/adapters'
|
98
|
+
|
99
|
+
require 'rr/deprecations'
|
103
100
|
|
104
101
|
require 'rr/version'
|
105
102
|
|
106
103
|
module RR
|
107
104
|
class << self
|
108
|
-
include
|
105
|
+
include DSL
|
109
106
|
|
110
107
|
(RR::Space.instance_methods - Object.instance_methods).each do |method_name|
|
111
108
|
class_eval((<<-METHOD), __FILE__, __LINE__ + 1)
|
@@ -117,10 +114,6 @@ module RR
|
|
117
114
|
|
118
115
|
attr_accessor :debug
|
119
116
|
alias_method :debug?, :debug
|
120
|
-
|
121
|
-
def ruby_18?
|
122
|
-
RUBY_VERSION =~ /^1\.8/
|
123
|
-
end
|
124
117
|
end
|
125
118
|
end
|
126
119
|
|
data/rr.gemspec
CHANGED
@@ -6,11 +6,11 @@ require File.expand_path('../lib/rr/version', __FILE__)
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = 'rr'
|
8
8
|
gem.version = RR.version
|
9
|
-
gem.authors = ['Brian Takita', 'Elliot Winkler']
|
10
|
-
gem.email = ['
|
9
|
+
gem.authors = ['Kouhei Sutou', 'Brian Takita', 'Elliot Winkler']
|
10
|
+
gem.email = ['kou@cozmixng.org']
|
11
11
|
gem.description = 'RR is a test double framework that features a rich selection of double techniques and a terse syntax.'
|
12
12
|
gem.summary = 'RR is a test double framework that features a rich selection of double techniques and a terse syntax.'
|
13
|
-
gem.homepage = '
|
13
|
+
gem.homepage = 'https://rr.github.io/rr'
|
14
14
|
gem.license = 'MIT'
|
15
15
|
|
16
16
|
gem.files = FileList[
|
@@ -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
|
@@ -33,6 +33,18 @@ class DefinesSpecSuiteTasks
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
require 'rspec/core/rake_task'
|
38
|
+
|
39
|
+
desc "Run the unit tests"
|
40
|
+
RSpec::Core::RakeTask.new(:unit) do |t|
|
41
|
+
t.pattern = 'spec/suites/rspec_2/unit/**/*_spec.rb'
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "Run the functional (API) tests"
|
45
|
+
RSpec::Core::RakeTask.new(:functional) do |t|
|
46
|
+
t.pattern = 'spec/suites/rspec_2/functional/**/*_spec.rb'
|
47
|
+
end
|
36
48
|
end
|
37
49
|
|
38
50
|
namespace :travis do
|
data/spec/global_helper.rb
CHANGED
@@ -30,4 +30,9 @@ module RR
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
lib_path = File.expand_path("../../lib", __FILE__)
|
34
|
+
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
|
35
|
+
|
33
36
|
Dir[ File.expand_path('../support/**/*.rb', __FILE__) ].each { |fn| require fn }
|
37
|
+
|
38
|
+
$stdout.sync = true
|
@@ -26,18 +26,12 @@ class SpecSuiteConfiguration
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def current_ruby_id
|
29
|
-
|
29
|
+
'19'
|
30
30
|
end
|
31
31
|
|
32
32
|
def matching_current_ruby_version?
|
33
33
|
ruby_id == current_ruby_id
|
34
34
|
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def ruby_18?
|
39
|
-
RUBY_VERSION =~ /^1\.8/
|
40
|
-
end
|
41
35
|
end
|
42
36
|
|
43
37
|
attr_reader :ruby_groups, :runners
|
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
10
|
SPEC_OPTS: '--require $PWD/spec/custom_formatter_for_rspec_2 --format CustomFormatterForRSpec2 --backtrace'
|