rr 0.3.11 → 0.4.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.
- data/CHANGES +8 -3
- data/README +130 -39
- data/Rakefile +6 -5
- data/lib/rr.rb +8 -8
- data/lib/rr/adapters/rr_methods.rb +228 -0
- data/lib/rr/adapters/rspec.rb +1 -1
- data/lib/rr/adapters/test_unit.rb +1 -1
- data/lib/rr/double.rb +294 -89
- data/lib/rr/{scenario_creator.rb → double_creator.rb} +65 -66
- data/lib/rr/{scenario_definition.rb → double_definition.rb} +36 -36
- data/lib/rr/{scenario_definition_builder.rb → double_definition_builder.rb} +3 -3
- data/lib/rr/double_insertion.rb +132 -0
- data/lib/rr/{scenario_matches.rb → double_matches.rb} +2 -2
- data/lib/rr/{scenario_method_proxy.rb → double_method_proxy.rb} +2 -2
- data/lib/rr/errors/argument_equality_error.rb +3 -3
- data/lib/rr/errors/rr_error.rb +13 -13
- data/lib/rr/errors/scenario_definition_error.rb +3 -3
- data/lib/rr/errors/scenario_not_found_error.rb +3 -3
- data/lib/rr/errors/scenario_order_error.rb +3 -3
- data/lib/rr/errors/times_called_error.rb +3 -3
- data/lib/rr/expectations/any_argument_expectation.rb +1 -1
- data/lib/rr/expectations/argument_equality_expectation.rb +1 -1
- data/lib/rr/expectations/times_called_expectation.rb +1 -1
- data/lib/rr/hash_with_object_id_key.rb +1 -1
- data/lib/rr/space.rb +40 -40
- data/lib/rr/times_called_matchers/any_times_matcher.rb +13 -13
- data/lib/rr/times_called_matchers/at_least_matcher.rb +11 -11
- data/lib/rr/times_called_matchers/at_most_matcher.rb +16 -16
- data/lib/rr/times_called_matchers/integer_matcher.rb +13 -13
- data/lib/rr/times_called_matchers/non_terminal.rb +21 -21
- data/lib/rr/times_called_matchers/proc_matcher.rb +7 -7
- data/lib/rr/times_called_matchers/range_matcher.rb +14 -14
- data/lib/rr/times_called_matchers/terminal.rb +16 -16
- data/lib/rr/times_called_matchers/times_called_matcher.rb +32 -32
- data/spec/core_spec_suite.rb +18 -0
- data/{examples → spec}/environment_fixture_setup.rb +0 -1
- data/{examples/high_level_example.rb → spec/high_level_spec.rb} +11 -11
- data/spec/rr/adapters/rr_methods_argument_matcher_spec.rb +67 -0
- data/spec/rr/adapters/rr_methods_creator_spec.rb +365 -0
- data/spec/rr/adapters/rr_methods_space_spec.rb +134 -0
- data/spec/rr/adapters/rr_methods_spec_helper.rb +11 -0
- data/{examples/rr/extensions/instance_methods_times_matcher_example.rb → spec/rr/adapters/rr_methods_times_matcher_spec.rb} +4 -4
- data/spec/rr/double/double_insertion_bind_spec.rb +78 -0
- data/spec/rr/double/double_insertion_dispatching_spec.rb +221 -0
- data/spec/rr/double/double_insertion_has_original_method_spec.rb +56 -0
- data/spec/rr/double/double_insertion_register_scenario_spec.rb +24 -0
- data/spec/rr/double/double_insertion_reset_spec.rb +89 -0
- data/spec/rr/double/double_insertion_spec.rb +66 -0
- data/spec/rr/double/double_insertion_verify_spec.rb +23 -0
- data/spec/rr/double_creator_spec.rb +454 -0
- data/{examples/rr/scenario_definition_example.rb → spec/rr/double_definition_spec.rb} +143 -143
- data/spec/rr/double_method_proxy_spec.rb +71 -0
- data/spec/rr/double_spec.rb +654 -0
- data/spec/rr/errors/rr_error_spec.rb +65 -0
- data/spec/rr/expectations/any_argument_expectation_spec.rb +47 -0
- data/spec/rr/expectations/anything_argument_equality_expectation_spec.rb +38 -0
- data/spec/rr/expectations/argument_equality_expectation_spec.rb +58 -0
- data/spec/rr/expectations/boolean_argument_equality_expectation_spec.rb +53 -0
- data/spec/rr/expectations/duck_type_argument_equality_expectation_spec.rb +71 -0
- data/spec/rr/expectations/is_a_argument_equality_expectation_spec.rb +51 -0
- data/spec/rr/expectations/numeric_argument_equality_expectation_spec.rb +47 -0
- data/spec/rr/expectations/range_argument_equality_expectation_spec.rb +59 -0
- data/spec/rr/expectations/regexp_argument_equality_expectation_spec.rb +72 -0
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_any_times_spec.rb +43 -0
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb +67 -0
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_most_spec.rb +71 -0
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +21 -0
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_integer_spec.rb +103 -0
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb +79 -0
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb +81 -0
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_spec.rb +40 -0
- data/spec/rr/rspec/rspec_adapter_spec.rb +65 -0
- data/spec/rr/rspec/rspec_backtrace_tweaking_spec.rb +52 -0
- data/spec/rr/rspec/rspec_usage_spec.rb +67 -0
- data/spec/rr/space/hash_with_object_id_key_spec.rb +88 -0
- data/spec/rr/space/space_create_spec.rb +278 -0
- data/spec/rr/space/space_helper.rb +7 -0
- data/spec/rr/space/space_register_spec.rb +32 -0
- data/spec/rr/space/space_reset_spec.rb +131 -0
- data/spec/rr/space/space_spec.rb +32 -0
- data/spec/rr/space/space_verify_spec.rb +181 -0
- data/{examples → spec}/rr/test_unit/test_helper.rb +1 -1
- data/{examples → spec}/rr/test_unit/test_unit_backtrace_test.rb +0 -0
- data/{examples → spec}/rr/test_unit/test_unit_integration_test.rb +4 -4
- data/spec/rr/times_called_matchers/any_times_matcher_spec.rb +47 -0
- data/spec/rr/times_called_matchers/at_least_matcher_spec.rb +55 -0
- data/spec/rr/times_called_matchers/at_most_matcher_spec.rb +70 -0
- data/spec/rr/times_called_matchers/integer_matcher_spec.rb +70 -0
- data/spec/rr/times_called_matchers/proc_matcher_spec.rb +55 -0
- data/spec/rr/times_called_matchers/range_matcher_spec.rb +76 -0
- data/spec/rr/times_called_matchers/times_called_matcher_spec.rb +118 -0
- data/spec/rspec_spec_suite.rb +16 -0
- data/spec/spec_helper.rb +9 -0
- data/{examples/example_suite.rb → spec/spec_suite.rb} +3 -3
- data/{examples/test_unit_example_suite.rb → spec/test_unit_spec_suite.rb} +0 -0
- metadata +93 -93
- data/examples/core_example_suite.rb +0 -31
- data/examples/example_helper.rb +0 -9
- data/examples/rr/double/double_bind_example.rb +0 -70
- data/examples/rr/double/double_dispatching_example.rb +0 -236
- data/examples/rr/double/double_example.rb +0 -66
- data/examples/rr/double/double_has_original_method_example.rb +0 -56
- data/examples/rr/double/double_register_scenario_example.rb +0 -24
- data/examples/rr/double/double_reset_example.rb +0 -89
- data/examples/rr/double/double_verify_example.rb +0 -23
- data/examples/rr/errors/rr_error_example.rb +0 -65
- data/examples/rr/expectations/any_argument_expectation_example.rb +0 -52
- data/examples/rr/expectations/anything_argument_equality_expectation_example.rb +0 -38
- data/examples/rr/expectations/argument_equality_expectation_example.rb +0 -62
- data/examples/rr/expectations/boolean_argument_equality_expectation_example.rb +0 -48
- data/examples/rr/expectations/duck_type_argument_equality_expectation_example.rb +0 -67
- data/examples/rr/expectations/is_a_argument_equality_expectation_example.rb +0 -50
- data/examples/rr/expectations/numeric_argument_equality_expectation_example.rb +0 -46
- data/examples/rr/expectations/range_argument_equality_expectation_example.rb +0 -59
- data/examples/rr/expectations/regexp_argument_equality_expectation_example.rb +0 -67
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_any_times_example.rb +0 -50
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_at_least_example.rb +0 -73
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_at_most_example.rb +0 -77
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_example.rb +0 -42
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +0 -20
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_integer_example.rb +0 -111
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_proc_example.rb +0 -88
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_range_example.rb +0 -90
- data/examples/rr/extensions/instance_methods_argument_matcher_example.rb +0 -65
- data/examples/rr/extensions/instance_methods_creator_example.rb +0 -363
- data/examples/rr/extensions/instance_methods_example_helper.rb +0 -11
- data/examples/rr/extensions/instance_methods_space_example.rb +0 -122
- data/examples/rr/rspec/rspec_adapter_example.rb +0 -63
- data/examples/rr/rspec/rspec_backtrace_tweaking_example.rb +0 -36
- data/examples/rr/rspec/rspec_usage_example.rb +0 -65
- data/examples/rr/scenario_creator_example.rb +0 -459
- data/examples/rr/scenario_example.rb +0 -701
- data/examples/rr/scenario_method_proxy_example.rb +0 -71
- data/examples/rr/space/hash_with_object_id_key_example.rb +0 -86
- data/examples/rr/space/space_create_example.rb +0 -278
- data/examples/rr/space/space_example.rb +0 -29
- data/examples/rr/space/space_helper.rb +0 -7
- data/examples/rr/space/space_register_example.rb +0 -32
- data/examples/rr/space/space_reset_example.rb +0 -120
- data/examples/rr/space/space_verify_example.rb +0 -169
- data/examples/rr/times_called_matchers/any_times_matcher_example.rb +0 -63
- data/examples/rr/times_called_matchers/at_least_matcher_example.rb +0 -70
- data/examples/rr/times_called_matchers/at_most_matcher_example.rb +0 -85
- data/examples/rr/times_called_matchers/integer_matcher_example.rb +0 -91
- data/examples/rr/times_called_matchers/proc_matcher_example.rb +0 -77
- data/examples/rr/times_called_matchers/range_matcher_example.rb +0 -97
- data/examples/rr/times_called_matchers/times_called_matcher_example.rb +0 -53
- data/examples/rspec_example_suite.rb +0 -25
- data/lib/rr/extensions/instance_methods.rb +0 -228
- data/lib/rr/scenario.rb +0 -337
data/lib/rr/space.rb
CHANGED
@@ -15,10 +15,10 @@ module RR
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
attr_reader :
|
18
|
+
attr_reader :double_insertions, :ordered_scenarios
|
19
19
|
attr_accessor :trim_backtrace
|
20
20
|
def initialize
|
21
|
-
@
|
21
|
+
@double_insertions = HashWithObjectIdKey.new
|
22
22
|
@ordered_scenarios = []
|
23
23
|
@trim_backtrace = false
|
24
24
|
end
|
@@ -27,103 +27,103 @@ module RR
|
|
27
27
|
if method_name && definition
|
28
28
|
raise ArgumentError, "Cannot pass in a method name and a block"
|
29
29
|
end
|
30
|
-
proxy =
|
30
|
+
proxy = DoubleMethodProxy.new(self, creator, object, &definition)
|
31
31
|
return proxy unless method_name
|
32
32
|
proxy.__send__(method_name)
|
33
33
|
end
|
34
34
|
|
35
|
-
# Creates a
|
35
|
+
# Creates a DoubleCreator.
|
36
36
|
def scenario_creator
|
37
|
-
|
37
|
+
DoubleCreator.new(self)
|
38
38
|
end
|
39
39
|
|
40
|
-
# Creates and registers a
|
41
|
-
def scenario(
|
42
|
-
scenario =
|
40
|
+
# Creates and registers a Double to be verified.
|
41
|
+
def scenario(double_insertion, definition = scenario_definition)
|
42
|
+
scenario = Double.new(self, double_insertion, definition)
|
43
43
|
scenario.definition.scenario = scenario
|
44
|
-
|
44
|
+
double_insertion.register_scenario scenario
|
45
45
|
scenario
|
46
46
|
end
|
47
47
|
|
48
48
|
def scenario_definition
|
49
|
-
|
49
|
+
DoubleDefinition.new(self)
|
50
50
|
end
|
51
51
|
|
52
|
-
# Reuses or creates, if none exists, a
|
52
|
+
# Reuses or creates, if none exists, a DoubleInsertion for the passed
|
53
53
|
# in object and method_name.
|
54
|
-
# When a
|
54
|
+
# When a DoubleInsertion is created, it binds the dispatcher to the
|
55
55
|
# object.
|
56
|
-
def
|
57
|
-
|
58
|
-
return
|
56
|
+
def double_insertion(object, method_name)
|
57
|
+
double_insertion = @double_insertions[object][method_name.to_sym]
|
58
|
+
return double_insertion if double_insertion
|
59
59
|
|
60
|
-
|
61
|
-
@
|
62
|
-
|
63
|
-
|
60
|
+
double_insertion = DoubleInsertion.new(self, object, method_name.to_sym)
|
61
|
+
@double_insertions[object][method_name.to_sym] = double_insertion
|
62
|
+
double_insertion.bind
|
63
|
+
double_insertion
|
64
64
|
end
|
65
65
|
|
66
|
-
# Registers the ordered
|
66
|
+
# Registers the ordered Double to be verified.
|
67
67
|
def register_ordered_scenario(scenario)
|
68
68
|
@ordered_scenarios << scenario
|
69
69
|
end
|
70
70
|
|
71
|
-
# Verifies that the passed in ordered
|
71
|
+
# Verifies that the passed in ordered Double is being called
|
72
72
|
# in the correct position.
|
73
73
|
def verify_ordered_scenario(scenario)
|
74
74
|
unless scenario.terminal?
|
75
|
-
raise Errors::
|
76
|
-
"Ordered
|
75
|
+
raise Errors::DoubleOrderError,
|
76
|
+
"Ordered Doubles cannot have a NonTerminal TimesCalledExpectation"
|
77
77
|
end
|
78
78
|
unless @ordered_scenarios.first == scenario
|
79
|
-
message =
|
79
|
+
message = Double.formatted_name(scenario.method_name, scenario.expected_arguments)
|
80
80
|
message << " called out of order in list\n"
|
81
|
-
message <<
|
82
|
-
raise Errors::
|
81
|
+
message << Double.list_message_part(@ordered_scenarios)
|
82
|
+
raise Errors::DoubleOrderError, message
|
83
83
|
end
|
84
84
|
@ordered_scenarios.shift unless scenario.attempt?
|
85
85
|
scenario
|
86
86
|
end
|
87
87
|
|
88
|
-
# Verifies all the
|
88
|
+
# Verifies all the DoubleInsertion objects have met their
|
89
89
|
# TimesCalledExpectations.
|
90
|
-
def
|
91
|
-
@
|
90
|
+
def verify_double_insertions
|
91
|
+
@double_insertions.each do |object, method_double_map|
|
92
92
|
method_double_map.keys.each do |method_name|
|
93
93
|
verify_double(object, method_name)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
# Resets the registered Doubles and ordered
|
98
|
+
# Resets the registered Doubles and ordered Doubles
|
99
99
|
def reset
|
100
100
|
reset_ordered_scenarios
|
101
|
-
|
101
|
+
reset_double_insertions
|
102
102
|
end
|
103
103
|
|
104
|
-
# Verifies the
|
104
|
+
# Verifies the DoubleInsertion for the passed in object and method_name.
|
105
105
|
def verify_double(object, method_name)
|
106
|
-
@
|
106
|
+
@double_insertions[object][method_name].verify
|
107
107
|
ensure
|
108
108
|
reset_double object, method_name
|
109
109
|
end
|
110
110
|
|
111
|
-
# Resets the
|
111
|
+
# Resets the DoubleInsertion for the passed in object and method_name.
|
112
112
|
def reset_double(object, method_name)
|
113
|
-
|
114
|
-
@
|
115
|
-
|
113
|
+
double_insertion = @double_insertions[object].delete(method_name)
|
114
|
+
@double_insertions.delete(object) if @double_insertions[object].empty?
|
115
|
+
double_insertion.reset
|
116
116
|
end
|
117
117
|
|
118
118
|
protected
|
119
|
-
# Removes the ordered
|
119
|
+
# Removes the ordered Doubles from the list
|
120
120
|
def reset_ordered_scenarios
|
121
121
|
@ordered_scenarios.clear
|
122
122
|
end
|
123
123
|
|
124
124
|
# Resets the registered Doubles for the next test run.
|
125
|
-
def
|
126
|
-
@
|
125
|
+
def reset_double_insertions
|
126
|
+
@double_insertions.each do |object, method_double_map|
|
127
127
|
method_double_map.keys.each do |method_name|
|
128
128
|
reset_double(object, method_name)
|
129
129
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
module RR
|
2
|
-
module TimesCalledMatchers
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
end
|
2
|
+
module TimesCalledMatchers #:nodoc:
|
3
|
+
class AnyTimesMatcher < TimesCalledMatcher
|
4
|
+
include NonTerminal
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
def initialize
|
7
|
+
end
|
8
|
+
|
9
|
+
def matches?(times_called)
|
10
|
+
true
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
protected
|
14
|
+
def expected_message_part
|
15
|
+
"Expected any number of times."
|
16
|
+
end
|
16
17
|
end
|
17
18
|
end
|
18
|
-
end
|
19
19
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
module RR
|
2
|
-
module TimesCalledMatchers
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
module TimesCalledMatchers #:nodoc:
|
3
|
+
class AtLeastMatcher < TimesCalledMatcher
|
4
|
+
include NonTerminal
|
5
|
+
|
6
|
+
def matches?(times_called)
|
7
|
+
times_called >= @times
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
protected
|
11
|
+
def expected_message_part
|
12
|
+
"Expected at least #{@times.inspect} times."
|
13
|
+
end
|
13
14
|
end
|
14
15
|
end
|
15
|
-
end
|
16
16
|
end
|
@@ -1,24 +1,24 @@
|
|
1
1
|
module RR
|
2
|
-
module TimesCalledMatchers
|
3
|
-
|
4
|
-
|
2
|
+
module TimesCalledMatchers #:nodoc:
|
3
|
+
class AtMostMatcher < TimesCalledMatcher
|
4
|
+
include Terminal
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def possible_match?(times_called)
|
7
|
+
times_called <= @times
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def matches?(times_called)
|
11
|
+
times_called <= @times
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
def attempt?(times_called)
|
15
|
+
times_called < @times
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
protected
|
19
|
+
def expected_message_part
|
20
|
+
"Expected at most #{@times.inspect} times."
|
21
|
+
end
|
21
22
|
end
|
22
23
|
end
|
23
|
-
end
|
24
24
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
module RR
|
2
|
-
module TimesCalledMatchers
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def possible_match?(times_called)
|
7
|
-
times_called <= @times
|
8
|
-
end
|
2
|
+
module TimesCalledMatchers #:nodoc:
|
3
|
+
class IntegerMatcher < TimesCalledMatcher
|
4
|
+
include Terminal
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
def possible_match?(times_called)
|
7
|
+
times_called <= @times
|
8
|
+
end
|
9
|
+
|
10
|
+
def matches?(times_called)
|
11
|
+
times_called == @times
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
def attempt?(times_called)
|
15
|
+
times_called < @times
|
16
|
+
end
|
16
17
|
end
|
17
18
|
end
|
18
|
-
end
|
19
19
|
end
|
@@ -1,27 +1,27 @@
|
|
1
1
|
module RR
|
2
|
-
module TimesCalledMatchers
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
2
|
+
module TimesCalledMatchers
|
3
|
+
# Including this module marks the TimesCalledMatcher as NonTerminal.
|
4
|
+
# Being NonTerminal means the Double will not "terminate" even when
|
5
|
+
# called infinite times.
|
6
|
+
#
|
7
|
+
# The Double that uses a NonTerminal TimesCalledMatcher will
|
8
|
+
# continue using the Double when passed the matching arguments.
|
9
|
+
# This is done by the attempt? always returning true.
|
10
|
+
#
|
11
|
+
# This is in opposition to Terminal TimesCalledMatchers, where
|
12
|
+
# attempt? will eventually return false.
|
13
|
+
module NonTerminal #:nodoc:
|
14
|
+
def terminal?
|
15
|
+
false
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
def possible_match?(times_called)
|
19
|
+
true
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
def attempt?(times_called)
|
23
|
+
true
|
24
|
+
end
|
24
25
|
end
|
25
26
|
end
|
26
|
-
end
|
27
27
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module RR
|
2
|
-
module TimesCalledMatchers
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
module TimesCalledMatchers
|
3
|
+
class ProcMatcher < TimesCalledMatcher #:nodoc:
|
4
|
+
include NonTerminal
|
5
|
+
|
6
|
+
def matches?(times_called)
|
7
|
+
@times.call(times_called)
|
8
|
+
end
|
8
9
|
end
|
9
10
|
end
|
10
|
-
end
|
11
11
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
module RR
|
2
|
-
module TimesCalledMatchers
|
3
|
-
|
4
|
-
|
2
|
+
module TimesCalledMatchers
|
3
|
+
class RangeMatcher < TimesCalledMatcher #:nodoc:
|
4
|
+
include Terminal
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
def possible_match?(times_called)
|
7
|
+
return true if times_called < @times.begin
|
8
|
+
return true if @times.include?(times_called)
|
9
|
+
return false
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
def matches?(times_called)
|
13
|
+
@times.include?(times_called)
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
def attempt?(times_called)
|
17
|
+
possible_match?(times_called)
|
18
|
+
end
|
18
19
|
end
|
19
20
|
end
|
20
|
-
end
|
21
21
|
end
|