rr 0.3.11 → 0.4.0

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