rr 0.1.6 → 0.1.7
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 +7 -0
- data/Rakefile +1 -1
- data/examples/environment_fixture_setup.rb +1 -1
- data/examples/example_helper.rb +1 -0
- data/examples/high_level_example.rb +1 -2
- data/examples/rr/do_not_allow_creator_example.rb +1 -2
- data/examples/rr/double_bind_example.rb +1 -2
- data/examples/rr/double_dispatching_example.rb +2 -3
- data/examples/rr/double_example.rb +1 -2
- data/examples/rr/double_register_scenario_example.rb +1 -2
- data/examples/rr/double_reset_example.rb +1 -2
- data/examples/rr/double_verify_example.rb +1 -2
- data/examples/rr/errors/rr_error_example.rb +1 -2
- data/examples/rr/expectations/any_argument_expectation_example.rb +1 -2
- data/examples/rr/expectations/anything_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/boolean_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/duck_type_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/is_a_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/numeric_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/range_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/regexp_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_at_least_example.rb +74 -0
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_at_most_example.rb +69 -0
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +18 -0
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_integer_example.rb +102 -0
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_proc_example.rb +80 -0
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_range_example.rb +81 -0
- data/examples/rr/expectations/times_called_expectation_example.rb +1 -185
- data/examples/rr/extensions/double_methods_example.rb +3 -4
- data/examples/rr/mock_creator_example.rb +1 -2
- data/examples/rr/probe_creator_example.rb +1 -2
- data/examples/rr/rspec/rspec_adapter_example.rb +1 -2
- data/examples/rr/rspec/rspec_backtrace_tweaking_example.rb +1 -2
- data/examples/rr/rspec/rspec_usage_example.rb +1 -2
- data/examples/rr/scenario_example.rb +60 -15
- data/examples/rr/space_create_example.rb +1 -2
- data/examples/rr/space_example.rb +1 -2
- data/examples/rr/space_register_example.rb +1 -2
- data/examples/rr/space_reset_example.rb +51 -4
- data/examples/rr/space_verify_example.rb +4 -5
- data/examples/rr/stub_creator_example.rb +1 -2
- data/examples/rr/test_unit/test_helper.rb +1 -1
- data/examples/rr/times_called_matchers/at_least_matcher_example.rb +74 -0
- data/examples/rr/times_called_matchers/at_most_matcher_example.rb +82 -0
- data/examples/rr/times_called_matchers/integer_matcher_example.rb +88 -0
- data/examples/rr/times_called_matchers/proc_matcher_example.rb +74 -0
- data/examples/rr/times_called_matchers/range_matcher_example.rb +94 -0
- data/examples/rr/times_called_matchers/times_called_matcher_example.rb +53 -0
- data/lib/rr.rb +15 -7
- data/lib/rr/adapters/rspec.rb +2 -2
- data/lib/rr/adapters/test_unit.rb +1 -1
- data/lib/rr/double.rb +2 -2
- data/lib/rr/expectations/times_called_expectation.rb +14 -13
- data/lib/rr/extensions/double_methods.rb +5 -5
- data/lib/rr/scenario.rb +35 -7
- data/lib/rr/space.rb +20 -8
- data/lib/rr/times_called_matchers/at_least_matcher.rb +22 -0
- data/lib/rr/times_called_matchers/at_most_matcher.rb +22 -0
- data/lib/rr/times_called_matchers/integer_matcher.rb +17 -0
- data/lib/rr/times_called_matchers/proc_matcher.rb +17 -0
- data/lib/rr/times_called_matchers/range_matcher.rb +19 -0
- data/lib/rr/times_called_matchers/times_called_matcher.rb +44 -0
- data/lib/rr/wildcard_matchers/anything.rb +13 -0
- data/lib/rr/wildcard_matchers/boolean.rb +18 -0
- data/lib/rr/wildcard_matchers/duck_type.rb +24 -0
- data/lib/rr/wildcard_matchers/is_a.rb +20 -0
- data/lib/rr/wildcard_matchers/numeric.rb +9 -0
- data/lib/rr/{expectations/wildcard_matchers → wildcard_matchers}/range.rb +0 -0
- data/lib/rr/{expectations/wildcard_matchers → wildcard_matchers}/regexp.rb +0 -0
- metadata +27 -9
- data/lib/rr/expectations/wildcard_matchers/anything.rb +0 -15
- data/lib/rr/expectations/wildcard_matchers/boolean.rb +0 -20
- data/lib/rr/expectations/wildcard_matchers/duck_type.rb +0 -26
- data/lib/rr/expectations/wildcard_matchers/is_a.rb +0 -22
- data/lib/rr/expectations/wildcard_matchers/numeric.rb +0 -11
data/examples/rr/expectations/times_called_expectation/times_called_expectation_proc_example.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require "examples/example_helper"
|
2
|
+
|
3
|
+
module RR
|
4
|
+
module Expectations
|
5
|
+
describe TimesCalledExpectation, " with ProcMatcher", :shared => true do
|
6
|
+
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
7
|
+
|
8
|
+
before do
|
9
|
+
@expectation = TimesCalledExpectation.new {|value| value == 2}
|
10
|
+
@expected_line = __LINE__ - 1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
describe TimesCalledExpectation, "#verify" do
|
16
|
+
it_should_behave_like "RR::Expectations::TimesCalledExpectation with ProcMatcher"
|
17
|
+
|
18
|
+
it "matches a block" do
|
19
|
+
@expectation.verify.should == false
|
20
|
+
@expectation.attempt!
|
21
|
+
@expectation.verify.should == false
|
22
|
+
@expectation.attempt!
|
23
|
+
@expectation.verify.should == true
|
24
|
+
@expectation.attempt!
|
25
|
+
@expectation.verify.should == false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe TimesCalledExpectation, "#verify! when passed a block (== 2 times)" do
|
30
|
+
it_should_behave_like "RR::Expectations::TimesCalledExpectation with ProcMatcher"
|
31
|
+
|
32
|
+
it "passes after attempt! called 2 times" do
|
33
|
+
@expectation.attempt!
|
34
|
+
@expectation.attempt!
|
35
|
+
@expectation.verify!
|
36
|
+
end
|
37
|
+
|
38
|
+
it "fails after attempt! called 1 time" do
|
39
|
+
@expectation.attempt!
|
40
|
+
proc {@expectation.verify!}.should raise_error(Errors::TimesCalledError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "fails after attempt! called 3 times" do
|
44
|
+
@expectation.attempt!
|
45
|
+
@expectation.attempt!
|
46
|
+
@expectation.attempt!
|
47
|
+
proc {@expectation.verify!}.should raise_error(Errors::TimesCalledError)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe TimesCalledExpectation, "#attempt? with IntegerMatcher" do
|
52
|
+
it_should_behave_like "RR::Expectations::TimesCalledExpectation with ProcMatcher"
|
53
|
+
|
54
|
+
it "returns true when attempted less than expected times" do
|
55
|
+
1.times {@expectation.attempt!}
|
56
|
+
@expectation.should be_attempt
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns true when attempted expected times" do
|
60
|
+
2.times {@expectation.attempt!}
|
61
|
+
@expectation.should be_attempt
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns true when attempted more than expected times" do
|
65
|
+
3.times {@expectation.attempt!}
|
66
|
+
@expectation.should be_attempt
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe TimesCalledExpectation, "#attempt! for a proc expectation" do
|
71
|
+
it_should_behave_like "RR::Expectations::TimesCalledExpectation with ProcMatcher"
|
72
|
+
|
73
|
+
it "lets everything pass" do
|
74
|
+
@object.foobar
|
75
|
+
@object.foobar
|
76
|
+
@object.foobar
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/examples/rr/expectations/times_called_expectation/times_called_expectation_range_example.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require "examples/example_helper"
|
2
|
+
|
3
|
+
module RR
|
4
|
+
module Expectations
|
5
|
+
describe TimesCalledExpectation, " with RangeMatcher", :shared => true do
|
6
|
+
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
7
|
+
|
8
|
+
before do
|
9
|
+
@expectation = TimesCalledExpectation.new(1..2)
|
10
|
+
@expected_line = __LINE__ - 1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe TimesCalledExpectation, "#verify" do
|
15
|
+
it_should_behave_like "RR::Expectations::TimesCalledExpectation with RangeMatcher"
|
16
|
+
|
17
|
+
it "returns true when times called falls within a range" do
|
18
|
+
@expectation.verify.should == false
|
19
|
+
@expectation.attempt!
|
20
|
+
@expectation.verify.should == true
|
21
|
+
@expectation.attempt!
|
22
|
+
@expectation.verify.should == true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe TimesCalledExpectation, "#verify! when passed a Range (1..2)" do
|
27
|
+
it_should_behave_like "RR::Expectations::TimesCalledExpectation with RangeMatcher"
|
28
|
+
|
29
|
+
it "passes after attempt! called 1 time" do
|
30
|
+
@expectation.attempt!
|
31
|
+
@expectation.verify!
|
32
|
+
end
|
33
|
+
|
34
|
+
it "passes after attempt! called 2 times" do
|
35
|
+
@expectation.attempt!
|
36
|
+
@expectation.attempt!
|
37
|
+
@expectation.verify!
|
38
|
+
end
|
39
|
+
|
40
|
+
it "can't be called when attempt! is called 3 times" do
|
41
|
+
@expectation.attempt!
|
42
|
+
@expectation.attempt!
|
43
|
+
proc do
|
44
|
+
@expectation.attempt!
|
45
|
+
end.should raise_error(Errors::TimesCalledError, "Called 3 times. Expected 1..2 times.")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe TimesCalledExpectation, "#attempt? with RangeMatcher" do
|
50
|
+
it_should_behave_like "RR::Expectations::TimesCalledExpectation with RangeMatcher"
|
51
|
+
|
52
|
+
it "returns true when attempted less than low end of range" do
|
53
|
+
@expectation.should be_attempt
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns false when attempted in range" do
|
57
|
+
@expectation.attempt!
|
58
|
+
@expectation.should be_attempt
|
59
|
+
@expectation.attempt!
|
60
|
+
@expectation.should be_attempt
|
61
|
+
end
|
62
|
+
|
63
|
+
it "raises error before attempted more than expected times" do
|
64
|
+
2.times {@expectation.attempt!}
|
65
|
+
proc {@expectation.attempt!}.should raise_error(
|
66
|
+
Errors::TimesCalledError
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe TimesCalledExpectation, "#attempt! for a range expectation" do
|
72
|
+
it_should_behave_like "RR::Expectations::TimesCalledExpectation with RangeMatcher"
|
73
|
+
|
74
|
+
it "raises error when attempt! called more than range permits" do
|
75
|
+
@expectation.attempt!
|
76
|
+
@expectation.attempt!
|
77
|
+
raises_expectation_error {@expectation.attempt!}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -1,23 +1,7 @@
|
|
1
|
-
|
2
|
-
require "#{dir}/../../example_helper"
|
1
|
+
require "examples/example_helper"
|
3
2
|
|
4
3
|
module RR
|
5
4
|
module Expectations
|
6
|
-
describe TimesCalledExpectation, :shared => true do
|
7
|
-
before do
|
8
|
-
@space = Space.new
|
9
|
-
@object = Object.new
|
10
|
-
@method_name = :foobar
|
11
|
-
@double = @space.create_double(@object, @method_name)
|
12
|
-
@scenario = @space.create_scenario(@double)
|
13
|
-
@scenario.with_any_args
|
14
|
-
end
|
15
|
-
|
16
|
-
def raises_expectation_error(&block)
|
17
|
-
proc {block.call}.should raise_error(Errors::TimesCalledError)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
5
|
describe TimesCalledExpectation, ".new" do
|
22
6
|
it "doesn't accept both an argument and a block" do
|
23
7
|
proc do
|
@@ -25,173 +9,5 @@ describe TimesCalledExpectation, ".new" do
|
|
25
9
|
end.should raise_error(ArgumentError, "Cannot pass in both an argument and a block")
|
26
10
|
end
|
27
11
|
end
|
28
|
-
|
29
|
-
describe TimesCalledExpectation, "#verify" do
|
30
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
31
|
-
|
32
|
-
it "returns true when times called exactly matches an integer" do
|
33
|
-
@expectation = TimesCalledExpectation.new(2)
|
34
|
-
@expectation.verify.should == false
|
35
|
-
@expectation.verify_input
|
36
|
-
@expectation.verify.should == false
|
37
|
-
@expectation.verify_input
|
38
|
-
@expectation.verify.should == true
|
39
|
-
end
|
40
|
-
|
41
|
-
it "returns true when times called falls within a range" do
|
42
|
-
@expectation = TimesCalledExpectation.new(1..2)
|
43
|
-
|
44
|
-
@expectation.verify.should == false
|
45
|
-
@expectation.verify_input
|
46
|
-
@expectation.verify.should == true
|
47
|
-
@expectation.verify_input
|
48
|
-
@expectation.verify.should == true
|
49
|
-
end
|
50
|
-
|
51
|
-
it "matches a block" do
|
52
|
-
@expectation = TimesCalledExpectation.new {|value| value == 2}
|
53
|
-
|
54
|
-
@expectation.verify.should == false
|
55
|
-
@expectation.verify_input
|
56
|
-
@expectation.verify.should == false
|
57
|
-
@expectation.verify_input
|
58
|
-
@expectation.verify.should == true
|
59
|
-
@expectation.verify_input
|
60
|
-
@expectation.verify.should == false
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe TimesCalledExpectation, "#verify! when passed an Integer (2)" do
|
65
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
66
|
-
|
67
|
-
before do
|
68
|
-
@expectation = TimesCalledExpectation.new(2)
|
69
|
-
@expected_line = __LINE__ - 1
|
70
|
-
end
|
71
|
-
|
72
|
-
it "passes after verify_input called 2 times" do
|
73
|
-
@expectation.verify_input
|
74
|
-
@expectation.verify_input
|
75
|
-
@expectation.verify!
|
76
|
-
end
|
77
|
-
|
78
|
-
it "fails after verify_input called 1 time" do
|
79
|
-
@expectation.verify_input
|
80
|
-
proc {@expectation.verify!}.should raise_error(
|
81
|
-
Errors::TimesCalledError,
|
82
|
-
"Called 1 time. Expected 2."
|
83
|
-
)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "can't be called when verify_input is called 3 times" do
|
87
|
-
@expectation.verify_input
|
88
|
-
@expectation.verify_input
|
89
|
-
proc do
|
90
|
-
@expectation.verify_input
|
91
|
-
end.should raise_error(Errors::TimesCalledError, "Called 3 times. Expected 2.")
|
92
|
-
end
|
93
|
-
|
94
|
-
it "has a backtrace to where the TimesCalledExpectation was instantiated on failure" do
|
95
|
-
error = nil
|
96
|
-
begin
|
97
|
-
@expectation.verify!
|
98
|
-
rescue Errors::TimesCalledError => e
|
99
|
-
error = e
|
100
|
-
end
|
101
|
-
e.backtrace.first.should include(__FILE__)
|
102
|
-
e.backtrace.first.should include(":#{@expected_line}")
|
103
|
-
end
|
104
|
-
|
105
|
-
it "has an error message that includes the number of times called and expected number of times" do
|
106
|
-
proc do
|
107
|
-
@expectation.verify!
|
108
|
-
end.should raise_error(Errors::TimesCalledError, "Called 0 times. Expected 2.")
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe TimesCalledExpectation, "#verify! when passed a Range (1..2)" do
|
113
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
114
|
-
|
115
|
-
before do
|
116
|
-
@expectation = TimesCalledExpectation.new(1..2)
|
117
|
-
end
|
118
|
-
|
119
|
-
it "passes after verify_input called 1 time" do
|
120
|
-
@expectation.verify_input
|
121
|
-
@expectation.verify!
|
122
|
-
end
|
123
|
-
|
124
|
-
it "passes after verify_input called 2 times" do
|
125
|
-
@expectation.verify_input
|
126
|
-
@expectation.verify_input
|
127
|
-
@expectation.verify!
|
128
|
-
end
|
129
|
-
|
130
|
-
it "can't be called when verify_input is called 3 times" do
|
131
|
-
@expectation.verify_input
|
132
|
-
@expectation.verify_input
|
133
|
-
proc do
|
134
|
-
@expectation.verify_input
|
135
|
-
end.should raise_error(Errors::TimesCalledError, "Called 3 times. Expected 1..2.")
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
describe TimesCalledExpectation, "#verify! when passed a block (== 2 times)" do
|
140
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
141
|
-
|
142
|
-
before do
|
143
|
-
@expectation = TimesCalledExpectation.new {|value| value == 2}
|
144
|
-
end
|
145
|
-
|
146
|
-
it "passes after verify_input called 2 times" do
|
147
|
-
@expectation.verify_input
|
148
|
-
@expectation.verify_input
|
149
|
-
@expectation.verify!
|
150
|
-
end
|
151
|
-
|
152
|
-
it "fails after verify_input called 1 time" do
|
153
|
-
@expectation.verify_input
|
154
|
-
proc {@expectation.verify!}.should raise_error(Errors::TimesCalledError)
|
155
|
-
end
|
156
|
-
|
157
|
-
it "fails after verify_input called 3 times" do
|
158
|
-
@expectation.verify_input
|
159
|
-
@expectation.verify_input
|
160
|
-
@expectation.verify_input
|
161
|
-
proc {@expectation.verify!}.should raise_error(Errors::TimesCalledError)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
describe TimesCalledExpectation, "#verify_input for an integer expectation" do
|
166
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
167
|
-
|
168
|
-
it "raises error when verify_input called more than the expected number of times" do
|
169
|
-
@expectation = TimesCalledExpectation.new(1)
|
170
|
-
@expectation.verify_input
|
171
|
-
raises_expectation_error {@expectation.verify_input}
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
describe TimesCalledExpectation, "#verify_input for a range expectation" do
|
176
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
177
|
-
|
178
|
-
it "raises error when verify_input called more than range permits" do
|
179
|
-
@expectation = TimesCalledExpectation.new(1..2)
|
180
|
-
@expectation.verify_input
|
181
|
-
@expectation.verify_input
|
182
|
-
raises_expectation_error {@expectation.verify_input}
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe TimesCalledExpectation, "#verify_input for a proc expectation" do
|
187
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
188
|
-
|
189
|
-
it "lets everything pass" do
|
190
|
-
@expectation = TimesCalledExpectation.new {|times| times == 1}
|
191
|
-
@object.foobar
|
192
|
-
@object.foobar
|
193
|
-
@object.foobar
|
194
|
-
end
|
195
|
-
end
|
196
12
|
end
|
197
13
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require "#{dir}/../../example_helper"
|
1
|
+
require "examples/example_helper"
|
3
2
|
|
4
3
|
module RR
|
5
4
|
module Extensions
|
@@ -25,7 +24,7 @@ module Extensions
|
|
25
24
|
end
|
26
25
|
|
27
26
|
scenario = creator.foobar(1, 2) {:baz}
|
28
|
-
scenario.times_called_expectation.
|
27
|
+
scenario.times_called_expectation.matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
|
29
28
|
scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityError
|
30
29
|
scenario.argument_expectation.expected_arguments.should == [1, 2]
|
31
30
|
|
@@ -121,7 +120,7 @@ module Extensions
|
|
121
120
|
end
|
122
121
|
|
123
122
|
scenario = creator.foobar(1, 2)
|
124
|
-
scenario.times_called_expectation.
|
123
|
+
scenario.times_called_expectation.matcher.should == TimesCalledMatchers::IntegerMatcher.new(0)
|
125
124
|
scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityError
|
126
125
|
scenario.argument_expectation.expected_arguments.should == [1, 2]
|
127
126
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require "#{dir}/../example_helper"
|
1
|
+
require "examples/example_helper"
|
3
2
|
|
4
3
|
module RR
|
5
4
|
describe Scenario, :shared => true do
|
@@ -117,6 +116,53 @@ describe Scenario, "#twice" do
|
|
117
116
|
end
|
118
117
|
end
|
119
118
|
|
119
|
+
describe Scenario, "#at_least" do
|
120
|
+
it_should_behave_like "RR::Scenario"
|
121
|
+
|
122
|
+
it "returns self" do
|
123
|
+
@scenario.with_any_args.at_least(2).should === @scenario
|
124
|
+
end
|
125
|
+
|
126
|
+
it "sets up a Times Called Expectation with 1" do
|
127
|
+
@scenario.at_least(2)
|
128
|
+
@scenario.should be_attempt
|
129
|
+
@scenario.call
|
130
|
+
@scenario.should be_attempt
|
131
|
+
@scenario.call
|
132
|
+
@scenario.should_not be_attempt
|
133
|
+
end
|
134
|
+
|
135
|
+
it "sets return value when block passed in" do
|
136
|
+
@scenario.with_any_args.at_least(2) {:return_value}
|
137
|
+
@object.foobar.should == :return_value
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe Scenario, "#at_most" do
|
142
|
+
it_should_behave_like "RR::Scenario"
|
143
|
+
|
144
|
+
it "returns self" do
|
145
|
+
@scenario.with_any_args.at_most(2).should === @scenario
|
146
|
+
end
|
147
|
+
|
148
|
+
it "sets up a Times Called Expectation with 1" do
|
149
|
+
@scenario.at_most(2)
|
150
|
+
@scenario.call
|
151
|
+
@scenario.call
|
152
|
+
proc do
|
153
|
+
@scenario.call
|
154
|
+
end.should raise_error(
|
155
|
+
Errors::TimesCalledError,
|
156
|
+
"Called 3 times. Expected at most 2 times."
|
157
|
+
)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "sets return value when block passed in" do
|
161
|
+
@scenario.with_any_args.at_most(2) {:return_value}
|
162
|
+
@object.foobar.should == :return_value
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
120
166
|
describe Scenario, "#times" do
|
121
167
|
it_should_behave_like "RR::Scenario"
|
122
168
|
|
@@ -434,29 +480,28 @@ describe Scenario, "#wildcard_match?" do
|
|
434
480
|
end
|
435
481
|
end
|
436
482
|
|
437
|
-
describe Scenario, "#
|
483
|
+
describe Scenario, "#attempt?" do
|
438
484
|
it_should_behave_like "RR::Scenario"
|
439
485
|
|
440
|
-
it "returns
|
486
|
+
it "returns true when TimesCalledExpectation#attempt? is true" do
|
441
487
|
@scenario.with(1, 2, 3).twice
|
442
|
-
@
|
443
|
-
@scenario.
|
488
|
+
@scenario.call(1, 2, 3)
|
489
|
+
@scenario.times_called_expectation.should be_attempt
|
490
|
+
@scenario.should be_attempt
|
444
491
|
end
|
445
492
|
|
446
|
-
it "returns
|
493
|
+
it "returns false when TimesCalledExpectation#attempt? is true" do
|
447
494
|
@scenario.with(1, 2, 3).twice
|
448
|
-
@
|
449
|
-
@
|
450
|
-
@scenario.
|
495
|
+
@scenario.call(1, 2, 3)
|
496
|
+
@scenario.call(1, 2, 3)
|
497
|
+
@scenario.times_called_expectation.should_not be_attempt
|
498
|
+
@scenario.should_not be_attempt
|
451
499
|
end
|
452
500
|
|
453
|
-
it "returns
|
501
|
+
it "returns true when there is no Times Called expectation" do
|
454
502
|
@scenario.with(1, 2, 3)
|
455
503
|
@scenario.times_called_expectation.should be_nil
|
456
|
-
|
457
|
-
@scenario.should_not be_times_called_verified
|
458
|
-
@object.foobar(1, 2, 3)
|
459
|
-
@scenario.should_not be_times_called_verified
|
504
|
+
@scenario.should be_attempt
|
460
505
|
end
|
461
506
|
end
|
462
507
|
|