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
@@ -0,0 +1,7 @@
1
+ module RR
2
+ describe Space, :shared => true do
3
+ after(:each) do
4
+ Space.instance.verify_double_insertions
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,32 @@
1
+ require "spec/spec_helper"
2
+
3
+ module RR
4
+ describe Space, "#register_ordered_scenario" do
5
+ it_should_behave_like "RR::Space"
6
+
7
+ before(:each) do
8
+ @space = Space.new
9
+ @original_space = Space.instance
10
+ Space.instance = @space
11
+ @object = Object.new
12
+ @method_name = :foobar
13
+ @double_insertion = @space.double_insertion(@object, @method_name)
14
+ end
15
+
16
+ after(:each) do
17
+ Space.instance = @original_space
18
+ end
19
+
20
+ it "adds the ordered scenario to the ordered_scenarios collection" do
21
+ scenario1 = @space.scenario(@double_insertion)
22
+
23
+ @space.ordered_scenarios.should == []
24
+ @space.register_ordered_scenario scenario1
25
+ @space.ordered_scenarios.should == [scenario1]
26
+
27
+ scenario2 = @space.scenario(@double_insertion)
28
+ @space.register_ordered_scenario scenario2
29
+ @space.ordered_scenarios.should == [scenario1, scenario2]
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,131 @@
1
+ require "spec/spec_helper"
2
+
3
+ module RR
4
+ describe Space do
5
+ it_should_behave_like "RR::Space"
6
+ describe "#reset" do
7
+ before do
8
+ @space = Space.new
9
+ @object1 = Object.new
10
+ @object2 = Object.new
11
+ @method_name = :foobar
12
+ end
13
+
14
+ it "removes the ordered scenarios" do
15
+ double1 = @space.double_insertion(@object1, :foobar1)
16
+ double2 = @space.double_insertion(@object1, :foobar2)
17
+
18
+ scenario1 = @space.scenario(double1)
19
+ scenario2 = @space.scenario(double2)
20
+
21
+ scenario1.ordered
22
+ scenario2.ordered
23
+
24
+ @space.ordered_scenarios.should_not be_empty
25
+
26
+ @space.reset
27
+ @space.ordered_scenarios.should be_empty
28
+ end
29
+
30
+ it "resets all double_insertions" do
31
+ double1 = @space.double_insertion(@object1, @method_name)
32
+ double1_reset_calls = 0
33
+ (
34
+ class << double1;
35
+ self;
36
+ end).class_eval do
37
+ define_method(:reset) do ||
38
+ double1_reset_calls += 1
39
+ end
40
+ end
41
+ double2 = @space.double_insertion(@object2, @method_name)
42
+ double2_reset_calls = 0
43
+ (
44
+ class << double2;
45
+ self;
46
+ end).class_eval do
47
+ define_method(:reset) do ||
48
+ double2_reset_calls += 1
49
+ end
50
+ end
51
+
52
+ @space.reset
53
+ double1_reset_calls.should == 1
54
+ double2_reset_calls.should == 1
55
+ end
56
+ end
57
+
58
+ describe "#reset_double" do
59
+ before do
60
+ @space = Space.new
61
+ @object = Object.new
62
+ @method_name = :foobar
63
+ end
64
+
65
+ it "resets the double_insertions" do
66
+ double_insertion = @space.double_insertion(@object, @method_name)
67
+ @space.double_insertions[@object][@method_name].should === double_insertion
68
+ @object.methods.should include("__rr__#{@method_name}")
69
+
70
+ @space.reset_double(@object, @method_name)
71
+ @space.double_insertions[@object][@method_name].should be_nil
72
+ @object.methods.should_not include("__rr__#{@method_name}")
73
+ end
74
+
75
+ it "removes the object from the double_insertions map when it has no double_insertions" do
76
+ double1 = @space.double_insertion(@object, :foobar1)
77
+ double2 = @space.double_insertion(@object, :foobar2)
78
+
79
+ @space.double_insertions.include?(@object).should == true
80
+ @space.double_insertions[@object][:foobar1].should_not be_nil
81
+ @space.double_insertions[@object][:foobar2].should_not be_nil
82
+
83
+ @space.reset_double(@object, :foobar1)
84
+ @space.double_insertions.include?(@object).should == true
85
+ @space.double_insertions[@object][:foobar1].should be_nil
86
+ @space.double_insertions[@object][:foobar2].should_not be_nil
87
+
88
+ @space.reset_double(@object, :foobar2)
89
+ @space.double_insertions.include?(@object).should == false
90
+ end
91
+ end
92
+
93
+ describe "#reset_double_insertions" do
94
+ it_should_behave_like "RR::Space"
95
+
96
+ before do
97
+ @space = Space.new
98
+ @object1 = Object.new
99
+ @object2 = Object.new
100
+ @method_name = :foobar
101
+ end
102
+
103
+ it "resets the double_insertion and removes it from the double_insertions list" do
104
+ double1 = @space.double_insertion(@object1, @method_name)
105
+ double1_reset_calls = 0
106
+ (
107
+ class << double1;
108
+ self;
109
+ end).class_eval do
110
+ define_method(:reset) do ||
111
+ double1_reset_calls += 1
112
+ end
113
+ end
114
+ double2 = @space.double_insertion(@object2, @method_name)
115
+ double2_reset_calls = 0
116
+ (
117
+ class << double2;
118
+ self;
119
+ end).class_eval do
120
+ define_method(:reset) do ||
121
+ double2_reset_calls += 1
122
+ end
123
+ end
124
+
125
+ @space.send(:reset_double_insertions)
126
+ double1_reset_calls.should == 1
127
+ double2_reset_calls.should == 1
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,32 @@
1
+ require "spec/spec_helper"
2
+
3
+ module RR
4
+ describe Space, " class" do
5
+ it_should_behave_like "RR::Space"
6
+
7
+ before(:each) do
8
+ @original_space = Space.instance
9
+ @space = Space.new
10
+ Space.instance = @space
11
+ end
12
+
13
+ after(:each) do
14
+ Space.instance = @original_space
15
+ end
16
+
17
+ it "proxies to a singleton instance of Space" do
18
+ create_double_args = nil
19
+ (
20
+ class << @space;
21
+ self;
22
+ end).class_eval do
23
+ define_method :double_insertion do |*args|
24
+ create_double_args = args
25
+ end
26
+ end
27
+
28
+ Space.double_insertion(:foo, :bar)
29
+ create_double_args.should == [:foo, :bar]
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,181 @@
1
+ require "spec/spec_helper"
2
+
3
+ module RR
4
+ describe Space, "#verify_ordered_scenario", :shared => true do
5
+ before do
6
+ @space = Space.new
7
+ @object = Object.new
8
+ @method_name = :foobar
9
+ @double_insertion = @space.double_insertion(@object, @method_name)
10
+ end
11
+
12
+ it "raises an error when Double is NonTerminal" do
13
+ scenario = @space.scenario(@double_insertion)
14
+ @space.register_ordered_scenario(scenario)
15
+
16
+ scenario.any_number_of_times
17
+ scenario.should_not be_terminal
18
+
19
+ proc do
20
+ @space.verify_ordered_scenario(scenario)
21
+ end.should raise_error(
22
+ Errors::DoubleOrderError,
23
+ "Ordered Doubles cannot have a NonTerminal TimesCalledExpectation"
24
+ )
25
+ end
26
+ end
27
+
28
+ describe Space do
29
+ it_should_behave_like "RR::Space"
30
+
31
+ describe "#verify_double_insertions" do
32
+ before do
33
+ @space = Space.new
34
+ @object1 = Object.new
35
+ @object2 = Object.new
36
+ @method_name = :foobar
37
+ end
38
+
39
+ it "verifies and deletes the double_insertions" do
40
+ double1 = @space.double_insertion(@object1, @method_name)
41
+ double1_verify_calls = 0
42
+ double1_reset_calls = 0
43
+ (
44
+ class << double1;
45
+ self;
46
+ end).class_eval do
47
+ define_method(:verify) do ||
48
+ double1_verify_calls += 1
49
+ end
50
+ define_method(:reset) do ||
51
+ double1_reset_calls += 1
52
+ end
53
+ end
54
+ double2 = @space.double_insertion(@object2, @method_name)
55
+ double2_verify_calls = 0
56
+ double2_reset_calls = 0
57
+ (
58
+ class << double2;
59
+ self;
60
+ end).class_eval do
61
+ define_method(:verify) do ||
62
+ double2_verify_calls += 1
63
+ end
64
+ define_method(:reset) do ||
65
+ double2_reset_calls += 1
66
+ end
67
+ end
68
+
69
+ @space.verify_double_insertions
70
+ double1_verify_calls.should == 1
71
+ double2_verify_calls.should == 1
72
+ double1_reset_calls.should == 1
73
+ double1_reset_calls.should == 1
74
+ end
75
+ end
76
+
77
+ describe "#verify_double" do
78
+ it_should_behave_like "RR::Space"
79
+
80
+ before do
81
+ @space = Space.new
82
+ @object = Object.new
83
+ @method_name = :foobar
84
+ end
85
+
86
+ it "verifies and deletes the double_insertion" do
87
+ double_insertion = @space.double_insertion(@object, @method_name)
88
+ @space.double_insertions[@object][@method_name].should === double_insertion
89
+ @object.methods.should include("__rr__#{@method_name}")
90
+
91
+ verify_calls = 0
92
+ (
93
+ class << double_insertion;
94
+ self;
95
+ end).class_eval do
96
+ define_method(:verify) do ||
97
+ verify_calls += 1
98
+ end
99
+ end
100
+ @space.verify_double(@object, @method_name)
101
+ verify_calls.should == 1
102
+
103
+ @space.double_insertions[@object][@method_name].should be_nil
104
+ @object.methods.should_not include("__rr__#{@method_name}")
105
+ end
106
+
107
+ it "deletes the double_insertion when verifying the double_insertion raises an error" do
108
+ double_insertion = @space.double_insertion(@object, @method_name)
109
+ @space.double_insertions[@object][@method_name].should === double_insertion
110
+ @object.methods.should include("__rr__#{@method_name}")
111
+
112
+ verify_called = true
113
+ (
114
+ class << double_insertion;
115
+ self;
116
+ end).class_eval do
117
+ define_method(:verify) do ||
118
+ verify_called = true
119
+ raise "An Error"
120
+ end
121
+ end
122
+ proc {@space.verify_double(@object, @method_name)}.should raise_error
123
+ verify_called.should be_true
124
+
125
+ @space.double_insertions[@object][@method_name].should be_nil
126
+ @object.methods.should_not include("__rr__#{@method_name}")
127
+ end
128
+ end
129
+
130
+ describe "#verify_ordered_scenario where the passed in scenario is at the front of the queue" do
131
+ it_should_behave_like "RR::Space#verify_ordered_scenario"
132
+
133
+ it "keeps the scenario when times called is not verified" do
134
+ scenario = @space.scenario(@double_insertion)
135
+ @space.register_ordered_scenario(scenario)
136
+
137
+ scenario.twice
138
+ scenario.should be_attempt
139
+
140
+ @space.verify_ordered_scenario(scenario)
141
+ @space.ordered_scenarios.should include(scenario)
142
+ end
143
+
144
+ it "removes the scenario when times called expectation should no longer be attempted" do
145
+ scenario = @space.scenario(@double_insertion)
146
+ @space.register_ordered_scenario(scenario)
147
+
148
+ scenario.with(1).once
149
+ @object.foobar(1)
150
+ scenario.should_not be_attempt
151
+
152
+ @space.verify_ordered_scenario(scenario)
153
+ @space.ordered_scenarios.should_not include(scenario)
154
+ end
155
+ end
156
+
157
+ describe "#verify_ordered_scenario where the passed in scenario is not at the front of the queue" do
158
+ it_should_behave_like "RR::Space#verify_ordered_scenario"
159
+
160
+ it "raises error" do
161
+ first_scenario = scenario
162
+ second_scenario = scenario
163
+
164
+ proc do
165
+ @space.verify_ordered_scenario(second_scenario)
166
+ end.should raise_error(
167
+ Errors::DoubleOrderError,
168
+ "foobar() called out of order in list\n" <<
169
+ "- foobar()\n" <<
170
+ "- foobar()"
171
+ )
172
+ end
173
+
174
+ def scenario
175
+ scenario_definition = @space.scenario(@double_insertion).once
176
+ @space.register_ordered_scenario(scenario_definition.scenario)
177
+ scenario_definition.scenario
178
+ end
179
+ end
180
+ end
181
+ end
@@ -1,5 +1,5 @@
1
1
  dir = File.dirname(__FILE__)
2
- require "examples/environment_fixture_setup"
2
+ require "spec/environment_fixture_setup"
3
3
 
4
4
  require "test/unit"
5
5
 
@@ -21,21 +21,21 @@ class TestUnitIntegrationTest < Test::Unit::TestCase
21
21
  assert_equal :baz, @subject.foobar("any", "thing")
22
22
  end
23
23
 
24
- def test_using_a_mock_probe
24
+ def test_using_a_mock_proxy
25
25
  def @subject.foobar
26
26
  :baz
27
27
  end
28
28
 
29
- mock.probe(@subject).foobar
29
+ mock.proxy(@subject).foobar
30
30
  assert_equal :baz, @subject.foobar
31
31
  end
32
32
 
33
- def test_using_a_stub_probe
33
+ def test_using_a_stub_proxy
34
34
  def @subject.foobar
35
35
  :baz
36
36
  end
37
37
 
38
- stub.probe(@subject).foobar
38
+ stub.proxy(@subject).foobar
39
39
  assert_equal :baz, @subject.foobar
40
40
  end
41
41
 
@@ -0,0 +1,47 @@
1
+ require "spec/spec_helper"
2
+
3
+ module RR
4
+ module TimesCalledMatchers
5
+ describe AnyTimesMatcher do
6
+ attr_reader :matcher
7
+ before do
8
+ @matcher = AnyTimesMatcher.new
9
+ end
10
+
11
+ describe AnyTimesMatcher, "#possible_match?" do
12
+ it "always returns true" do
13
+ matcher.should be_possible_match(0)
14
+ matcher.should be_possible_match(99999)
15
+ end
16
+ end
17
+
18
+ describe AnyTimesMatcher, "#matches?" do
19
+ it "always returns true" do
20
+ matcher.should be_matches(0)
21
+ matcher.should be_matches(99999)
22
+ end
23
+ end
24
+
25
+ describe AnyTimesMatcher, "#attempt?" do
26
+ it "always returns true" do
27
+ matcher.should be_attempt(0)
28
+ matcher.should be_attempt(99999)
29
+ end
30
+ end
31
+
32
+ describe AnyTimesMatcher, "#terminal?" do
33
+ it "returns false" do
34
+ matcher.should_not be_terminal
35
+ end
36
+ end
37
+
38
+ describe AnyTimesMatcher, "#error_message" do
39
+ it "has an error message" do
40
+ matcher.error_message(2).should == (
41
+ "Called 2 times.\nExpected any number of times."
42
+ )
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end