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/examples/rr/expectations/times_called_expectation/times_called_expectation_at_most_example.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
require "examples/example_helper"
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module Expectations
|
5
|
-
describe TimesCalledExpectation, ' with AtMostMatcher', :shared => true do
|
6
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
7
|
-
|
8
|
-
before do
|
9
|
-
@times = 3
|
10
|
-
@at_most = TimesCalledMatchers::AtMostMatcher.new(@times)
|
11
|
-
@expectation = TimesCalledExpectation.new(@scenario, @at_most)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe TimesCalledExpectation, "#verify! with AtMostMatcher" do
|
16
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with AtMostMatcher"
|
17
|
-
|
18
|
-
it "returns true when times called == times" do
|
19
|
-
3.times {@expectation.attempt!}
|
20
|
-
@expectation.verify!
|
21
|
-
end
|
22
|
-
|
23
|
-
it "raises error when times called < times" do
|
24
|
-
2.times {@expectation.attempt!}
|
25
|
-
@expectation.verify!
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe TimesCalledExpectation, "#attempt? with AtMostMatcher" do
|
30
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with AtMostMatcher"
|
31
|
-
|
32
|
-
it "returns true when attempted less than expected times" do
|
33
|
-
2.times {@expectation.attempt!}
|
34
|
-
@expectation.should be_attempt
|
35
|
-
end
|
36
|
-
|
37
|
-
it "returns false when attempted expected times" do
|
38
|
-
3.times {@expectation.attempt!}
|
39
|
-
@expectation.should_not be_attempt
|
40
|
-
end
|
41
|
-
|
42
|
-
it "raises error before attempted more than expected times" do
|
43
|
-
3.times {@expectation.attempt!}
|
44
|
-
proc {@expectation.attempt!}.should raise_error(
|
45
|
-
Errors::TimesCalledError
|
46
|
-
)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe TimesCalledExpectation, "#attempt! with AtMostMatcher" do
|
51
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with AtMostMatcher"
|
52
|
-
|
53
|
-
it "fails when times called more than times" do
|
54
|
-
3.times {@expectation.attempt!}
|
55
|
-
proc do
|
56
|
-
@expectation.attempt!
|
57
|
-
end.should raise_error(Errors::TimesCalledError, "foobar()\nCalled 4 times.\nExpected at most 3 times.")
|
58
|
-
end
|
59
|
-
|
60
|
-
it "passes when times called == times" do
|
61
|
-
3.times {@expectation.attempt!}
|
62
|
-
end
|
63
|
-
|
64
|
-
it "passes when times called < times" do
|
65
|
-
@expectation.attempt!
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe TimesCalledExpectation, "#terminal? with AtMostMatcher" do
|
70
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with AtMostMatcher"
|
71
|
-
|
72
|
-
it "returns true" do
|
73
|
-
@expectation.should be_terminal
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require "examples/example_helper"
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module Expectations
|
5
|
-
describe TimesCalledExpectation, " with failure", :shared => true do
|
6
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
7
|
-
|
8
|
-
before do
|
9
|
-
@times = 0
|
10
|
-
@matcher = TimesCalledMatchers::IntegerMatcher.new(@times)
|
11
|
-
@expectation = TimesCalledExpectation.new(@scenario, @matcher)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe TimesCalledExpectation, "#attempt! with failure" do
|
16
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with failure"
|
17
|
-
|
18
|
-
it "raises error that includes the scenario" do
|
19
|
-
proc do
|
20
|
-
@expectation.attempt!
|
21
|
-
end.should raise_error(
|
22
|
-
Errors::TimesCalledError,
|
23
|
-
"#{@scenario.formatted_name}\n#{@matcher.error_message(1)}"
|
24
|
-
)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe TimesCalledExpectation, "#verify! with failure" do
|
29
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with failure"
|
30
|
-
|
31
|
-
it "raises error with passed in message prepended" do
|
32
|
-
@expectation.instance_variable_set(:@times_called, 1)
|
33
|
-
proc do
|
34
|
-
@expectation.verify!
|
35
|
-
end.should raise_error(
|
36
|
-
Errors::TimesCalledError,
|
37
|
-
"#{@scenario.formatted_name}\n#{@matcher.error_message(1)}"
|
38
|
-
)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require "examples/example_helper"
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module Expectations
|
5
|
-
describe TimesCalledExpectation, :shared => true do
|
6
|
-
before do
|
7
|
-
@space = Space.new
|
8
|
-
@object = Object.new
|
9
|
-
@method_name = :foobar
|
10
|
-
@double = @space.double(@object, @method_name)
|
11
|
-
@scenario = @space.scenario(@double)
|
12
|
-
@scenario.with_any_args
|
13
|
-
end
|
14
|
-
|
15
|
-
def raises_expectation_error(&block)
|
16
|
-
proc {block.call}.should raise_error(Errors::TimesCalledError)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/examples/rr/expectations/times_called_expectation/times_called_expectation_integer_example.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
require "examples/example_helper"
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module Expectations
|
5
|
-
describe TimesCalledExpectation, " with IntegerMatcher", :shared => true do
|
6
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
7
|
-
|
8
|
-
before do
|
9
|
-
@matcher = TimesCalledMatchers::IntegerMatcher.new(2)
|
10
|
-
@expectation = TimesCalledExpectation.new(@scenario, @matcher)
|
11
|
-
@expected_line = __LINE__ - 1
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe TimesCalledExpectation, "#verify" do
|
16
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with IntegerMatcher"
|
17
|
-
|
18
|
-
it "returns true when times called exactly matches an integer" do
|
19
|
-
@expectation.verify.should == false
|
20
|
-
@expectation.attempt!
|
21
|
-
@expectation.verify.should == false
|
22
|
-
@expectation.attempt!
|
23
|
-
@expectation.verify.should == true
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe TimesCalledExpectation, "#verify! when passed an Integer (2)" do
|
28
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with IntegerMatcher"
|
29
|
-
|
30
|
-
it "passes after attempt! called 2 times" do
|
31
|
-
@expectation.attempt!
|
32
|
-
@expectation.attempt!
|
33
|
-
@expectation.verify!
|
34
|
-
end
|
35
|
-
|
36
|
-
it "fails after attempt! called 1 time" do
|
37
|
-
@expectation.attempt!
|
38
|
-
proc {@expectation.verify!}.should raise_error(
|
39
|
-
Errors::TimesCalledError,
|
40
|
-
"foobar()\nCalled 1 time.\nExpected 2 times."
|
41
|
-
)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "can't be called when attempt! is called 3 times" do
|
45
|
-
@expectation.attempt!
|
46
|
-
@expectation.attempt!
|
47
|
-
proc do
|
48
|
-
@expectation.attempt!
|
49
|
-
end.should raise_error(Errors::TimesCalledError, "foobar()\nCalled 3 times.\nExpected 2 times.")
|
50
|
-
end
|
51
|
-
|
52
|
-
it "has a backtrace to where the TimesCalledExpectation was instantiated on failure" do
|
53
|
-
error = nil
|
54
|
-
begin
|
55
|
-
@expectation.verify!
|
56
|
-
rescue Errors::TimesCalledError => e
|
57
|
-
error = e
|
58
|
-
end
|
59
|
-
e.backtrace.first.should include(__FILE__)
|
60
|
-
e.backtrace.first.should include(":#{@expected_line}")
|
61
|
-
end
|
62
|
-
|
63
|
-
it "has an error message that includes the number of times called and expected number of times" do
|
64
|
-
proc do
|
65
|
-
@expectation.verify!
|
66
|
-
end.should raise_error(Errors::TimesCalledError, "foobar()\nCalled 0 times.\nExpected 2 times.")
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe TimesCalledExpectation, "#attempt? with IntegerMatcher" do
|
71
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with IntegerMatcher"
|
72
|
-
|
73
|
-
it "returns true when attempted less than expected times" do
|
74
|
-
1.times {@expectation.attempt!}
|
75
|
-
@expectation.should be_attempt
|
76
|
-
end
|
77
|
-
|
78
|
-
it "returns false when attempted expected times" do
|
79
|
-
2.times {@expectation.attempt!}
|
80
|
-
@expectation.should_not be_attempt
|
81
|
-
end
|
82
|
-
|
83
|
-
it "raises error before attempted more than expected times" do
|
84
|
-
2.times {@expectation.attempt!}
|
85
|
-
proc {@expectation.attempt!}.should raise_error(
|
86
|
-
Errors::TimesCalledError
|
87
|
-
)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe TimesCalledExpectation, "#attempt! for an IntegerMatcher" do
|
92
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with IntegerMatcher"
|
93
|
-
|
94
|
-
it "raises error when attempt! called more than the expected number of times" do
|
95
|
-
@expectation.attempt!
|
96
|
-
@expectation.attempt!
|
97
|
-
proc do
|
98
|
-
@expectation.attempt!
|
99
|
-
end.should raise_error(Errors::TimesCalledError)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe TimesCalledExpectation, "#terminal? with IntegerMatcher" do
|
104
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with IntegerMatcher"
|
105
|
-
|
106
|
-
it "returns true" do
|
107
|
-
@expectation.should be_terminal
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
data/examples/rr/expectations/times_called_expectation/times_called_expectation_proc_example.rb
DELETED
@@ -1,88 +0,0 @@
|
|
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
|
-
@matcher = TimesCalledMatchers::ProcMatcher.new(proc {|value| value == 2})
|
10
|
-
@expectation = TimesCalledExpectation.new(@scenario, @matcher)
|
11
|
-
@expected_line = __LINE__ - 1
|
12
|
-
end
|
13
|
-
end
|
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
|
-
|
80
|
-
describe TimesCalledExpectation, "#terminal? with ProcMatcher" do
|
81
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with ProcMatcher"
|
82
|
-
|
83
|
-
it "returns false" do
|
84
|
-
@expectation.should_not be_terminal
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
data/examples/rr/expectations/times_called_expectation/times_called_expectation_range_example.rb
DELETED
@@ -1,90 +0,0 @@
|
|
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
|
-
@matcher = TimesCalledMatchers::RangeMatcher.new(1..2)
|
10
|
-
@expectation = TimesCalledExpectation.new(@scenario, @matcher)
|
11
|
-
@expected_line = __LINE__ - 1
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe TimesCalledExpectation, "#verify" do
|
16
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with RangeMatcher"
|
17
|
-
|
18
|
-
it "returns true when times called falls within a range" do
|
19
|
-
@expectation.verify.should == false
|
20
|
-
@expectation.attempt!
|
21
|
-
@expectation.verify.should == true
|
22
|
-
@expectation.attempt!
|
23
|
-
@expectation.verify.should == true
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe TimesCalledExpectation, "#verify! when passed a Range (1..2)" do
|
28
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with RangeMatcher"
|
29
|
-
|
30
|
-
it "passes after attempt! called 1 time" do
|
31
|
-
@expectation.attempt!
|
32
|
-
@expectation.verify!
|
33
|
-
end
|
34
|
-
|
35
|
-
it "passes after attempt! called 2 times" do
|
36
|
-
@expectation.attempt!
|
37
|
-
@expectation.attempt!
|
38
|
-
@expectation.verify!
|
39
|
-
end
|
40
|
-
|
41
|
-
it "can't be called when attempt! is called 3 times" do
|
42
|
-
@expectation.attempt!
|
43
|
-
@expectation.attempt!
|
44
|
-
proc do
|
45
|
-
@expectation.attempt!
|
46
|
-
end.should raise_error(Errors::TimesCalledError, "foobar()\nCalled 3 times.\nExpected 1..2 times.")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe TimesCalledExpectation, "#attempt? with RangeMatcher" do
|
51
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with RangeMatcher"
|
52
|
-
|
53
|
-
it "returns true when attempted less than low end of range" do
|
54
|
-
@expectation.should be_attempt
|
55
|
-
end
|
56
|
-
|
57
|
-
it "returns false when attempted in range" do
|
58
|
-
@expectation.attempt!
|
59
|
-
@expectation.should be_attempt
|
60
|
-
@expectation.attempt!
|
61
|
-
@expectation.should be_attempt
|
62
|
-
end
|
63
|
-
|
64
|
-
it "raises error before attempted more than expected times" do
|
65
|
-
2.times {@expectation.attempt!}
|
66
|
-
proc {@expectation.attempt!}.should raise_error(
|
67
|
-
Errors::TimesCalledError
|
68
|
-
)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe TimesCalledExpectation, "#attempt! for a range expectation" do
|
73
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with RangeMatcher"
|
74
|
-
|
75
|
-
it "raises error when attempt! called more than range permits" do
|
76
|
-
@expectation.attempt!
|
77
|
-
@expectation.attempt!
|
78
|
-
raises_expectation_error {@expectation.attempt!}
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe TimesCalledExpectation, "#terminal? with RangeMatcher" do
|
83
|
-
it_should_behave_like "RR::Expectations::TimesCalledExpectation with RangeMatcher"
|
84
|
-
|
85
|
-
it "returns true" do
|
86
|
-
@expectation.should be_terminal
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require "examples/example_helper"
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module Extensions
|
5
|
-
describe InstanceMethods, "#anything" do
|
6
|
-
it_should_behave_like "RR::Extensions::InstanceMethods"
|
7
|
-
|
8
|
-
it "returns an Anything matcher" do
|
9
|
-
anything.should == WildcardMatchers::Anything.new
|
10
|
-
end
|
11
|
-
|
12
|
-
it "rr_anything returns an Anything matcher" do
|
13
|
-
rr_anything.should == WildcardMatchers::Anything.new
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe InstanceMethods, "#is_a" do
|
18
|
-
it_should_behave_like "RR::Extensions::InstanceMethods"
|
19
|
-
|
20
|
-
it "returns an IsA matcher" do
|
21
|
-
is_a(Integer).should == WildcardMatchers::IsA.new(Integer)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "rr_is_a returns an IsA matcher" do
|
25
|
-
rr_is_a(Integer).should == WildcardMatchers::IsA.new(Integer)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe InstanceMethods, "#numeric" do
|
30
|
-
it_should_behave_like "RR::Extensions::InstanceMethods"
|
31
|
-
|
32
|
-
it "returns an Numeric matcher" do
|
33
|
-
numeric.should == WildcardMatchers::Numeric.new
|
34
|
-
end
|
35
|
-
|
36
|
-
it "rr_numeric returns an Numeric matcher" do
|
37
|
-
rr_numeric.should == WildcardMatchers::Numeric.new
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe InstanceMethods, "#boolean" do
|
42
|
-
it_should_behave_like "RR::Extensions::InstanceMethods"
|
43
|
-
|
44
|
-
it "returns an Boolean matcher" do
|
45
|
-
boolean.should == WildcardMatchers::Boolean.new
|
46
|
-
end
|
47
|
-
|
48
|
-
it "rr_boolean returns an Boolean matcher" do
|
49
|
-
rr_boolean.should == WildcardMatchers::Boolean.new
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe InstanceMethods, "#duck_type" do
|
54
|
-
it_should_behave_like "RR::Extensions::InstanceMethods"
|
55
|
-
|
56
|
-
it "returns a DuckType matcher" do
|
57
|
-
duck_type(:one, :two).should == WildcardMatchers::DuckType.new(:one, :two)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "rr_duck_type returns a DuckType matcher" do
|
61
|
-
rr_duck_type(:one, :two).should == WildcardMatchers::DuckType.new(:one, :two)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|