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
@@ -1,32 +0,0 @@
|
|
1
|
-
require "examples/example_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 = @space.double(@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)
|
22
|
-
|
23
|
-
@space.ordered_scenarios.should == []
|
24
|
-
@space.register_ordered_scenario scenario1
|
25
|
-
@space.ordered_scenarios.should == [scenario1]
|
26
|
-
|
27
|
-
scenario2 = @space.scenario(@double)
|
28
|
-
@space.register_ordered_scenario scenario2
|
29
|
-
@space.ordered_scenarios.should == [scenario1, scenario2]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,120 +0,0 @@
|
|
1
|
-
require "examples/example_helper"
|
2
|
-
|
3
|
-
module RR
|
4
|
-
describe Space, "#reset" do
|
5
|
-
it_should_behave_like "RR::Space"
|
6
|
-
|
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(@object1, :foobar1)
|
16
|
-
double2 = @space.double(@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 doubles" do
|
31
|
-
double1 = @space.double(@object1, @method_name)
|
32
|
-
double1_reset_calls = 0
|
33
|
-
(class << double1; self; end).class_eval do
|
34
|
-
define_method(:reset) do ||
|
35
|
-
double1_reset_calls += 1
|
36
|
-
end
|
37
|
-
end
|
38
|
-
double2 = @space.double(@object2, @method_name)
|
39
|
-
double2_reset_calls = 0
|
40
|
-
(class << double2; self; end).class_eval do
|
41
|
-
define_method(:reset) do ||
|
42
|
-
double2_reset_calls += 1
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
@space.reset
|
47
|
-
double1_reset_calls.should == 1
|
48
|
-
double2_reset_calls.should == 1
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe Space, "#reset_double" do
|
53
|
-
it_should_behave_like "RR::Space"
|
54
|
-
|
55
|
-
before do
|
56
|
-
@space = Space.new
|
57
|
-
@object = Object.new
|
58
|
-
@method_name = :foobar
|
59
|
-
end
|
60
|
-
|
61
|
-
it "resets the doubles" do
|
62
|
-
double = @space.double(@object, @method_name)
|
63
|
-
@space.doubles[@object][@method_name].should === double
|
64
|
-
@object.methods.should include("__rr__#{@method_name}")
|
65
|
-
|
66
|
-
@space.reset_double(@object, @method_name)
|
67
|
-
@space.doubles[@object][@method_name].should be_nil
|
68
|
-
@object.methods.should_not include("__rr__#{@method_name}")
|
69
|
-
end
|
70
|
-
|
71
|
-
it "removes the object from the doubles map when it has no doubles" do
|
72
|
-
double1 = @space.double(@object, :foobar1)
|
73
|
-
double2 = @space.double(@object, :foobar2)
|
74
|
-
|
75
|
-
@space.doubles.include?(@object).should == true
|
76
|
-
@space.doubles[@object][:foobar1].should_not be_nil
|
77
|
-
@space.doubles[@object][:foobar2].should_not be_nil
|
78
|
-
|
79
|
-
@space.reset_double(@object, :foobar1)
|
80
|
-
@space.doubles.include?(@object).should == true
|
81
|
-
@space.doubles[@object][:foobar1].should be_nil
|
82
|
-
@space.doubles[@object][:foobar2].should_not be_nil
|
83
|
-
|
84
|
-
@space.reset_double(@object, :foobar2)
|
85
|
-
@space.doubles.include?(@object).should == false
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe Space, "#reset_doubles" do
|
90
|
-
it_should_behave_like "RR::Space"
|
91
|
-
|
92
|
-
before do
|
93
|
-
@space = Space.new
|
94
|
-
@object1 = Object.new
|
95
|
-
@object2 = Object.new
|
96
|
-
@method_name = :foobar
|
97
|
-
end
|
98
|
-
|
99
|
-
it "resets the double and removes it from the doubles list" do
|
100
|
-
double1 = @space.double(@object1, @method_name)
|
101
|
-
double1_reset_calls = 0
|
102
|
-
(class << double1; self; end).class_eval do
|
103
|
-
define_method(:reset) do ||
|
104
|
-
double1_reset_calls += 1
|
105
|
-
end
|
106
|
-
end
|
107
|
-
double2 = @space.double(@object2, @method_name)
|
108
|
-
double2_reset_calls = 0
|
109
|
-
(class << double2; self; end).class_eval do
|
110
|
-
define_method(:reset) do ||
|
111
|
-
double2_reset_calls += 1
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
@space.send(:reset_doubles)
|
116
|
-
double1_reset_calls.should == 1
|
117
|
-
double2_reset_calls.should == 1
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
@@ -1,169 +0,0 @@
|
|
1
|
-
require "examples/example_helper"
|
2
|
-
|
3
|
-
module RR
|
4
|
-
describe Space, "#verify_doubles" do
|
5
|
-
it_should_behave_like "RR::Space"
|
6
|
-
|
7
|
-
before do
|
8
|
-
@space = Space.new
|
9
|
-
@object1 = Object.new
|
10
|
-
@object2 = Object.new
|
11
|
-
@method_name = :foobar
|
12
|
-
end
|
13
|
-
|
14
|
-
it "verifies and deletes the doubles" do
|
15
|
-
double1 = @space.double(@object1, @method_name)
|
16
|
-
double1_verify_calls = 0
|
17
|
-
double1_reset_calls = 0
|
18
|
-
(class << double1; self; end).class_eval do
|
19
|
-
define_method(:verify) do ||
|
20
|
-
double1_verify_calls += 1
|
21
|
-
end
|
22
|
-
define_method(:reset) do ||
|
23
|
-
double1_reset_calls += 1
|
24
|
-
end
|
25
|
-
end
|
26
|
-
double2 = @space.double(@object2, @method_name)
|
27
|
-
double2_verify_calls = 0
|
28
|
-
double2_reset_calls = 0
|
29
|
-
(class << double2; self; end).class_eval do
|
30
|
-
define_method(:verify) do ||
|
31
|
-
double2_verify_calls += 1
|
32
|
-
end
|
33
|
-
define_method(:reset) do ||
|
34
|
-
double2_reset_calls += 1
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
@space.verify_doubles
|
39
|
-
double1_verify_calls.should == 1
|
40
|
-
double2_verify_calls.should == 1
|
41
|
-
double1_reset_calls.should == 1
|
42
|
-
double1_reset_calls.should == 1
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe Space, "#verify_double" do
|
47
|
-
it_should_behave_like "RR::Space"
|
48
|
-
|
49
|
-
before do
|
50
|
-
@space = Space.new
|
51
|
-
@object = Object.new
|
52
|
-
@method_name = :foobar
|
53
|
-
end
|
54
|
-
|
55
|
-
it "verifies and deletes the double" do
|
56
|
-
double = @space.double(@object, @method_name)
|
57
|
-
@space.doubles[@object][@method_name].should === double
|
58
|
-
@object.methods.should include("__rr__#{@method_name}")
|
59
|
-
|
60
|
-
verify_calls = 0
|
61
|
-
(class << double; self; end).class_eval do
|
62
|
-
define_method(:verify) do ||
|
63
|
-
verify_calls += 1
|
64
|
-
end
|
65
|
-
end
|
66
|
-
@space.verify_double(@object, @method_name)
|
67
|
-
verify_calls.should == 1
|
68
|
-
|
69
|
-
@space.doubles[@object][@method_name].should be_nil
|
70
|
-
@object.methods.should_not include("__rr__#{@method_name}")
|
71
|
-
end
|
72
|
-
|
73
|
-
it "deletes the double when verifying the double raises an error" do
|
74
|
-
double = @space.double(@object, @method_name)
|
75
|
-
@space.doubles[@object][@method_name].should === double
|
76
|
-
@object.methods.should include("__rr__#{@method_name}")
|
77
|
-
|
78
|
-
verify_called = true
|
79
|
-
(class << double; self; end).class_eval do
|
80
|
-
define_method(:verify) do ||
|
81
|
-
verify_called = true
|
82
|
-
raise "An Error"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
proc {@space.verify_double(@object, @method_name)}.should raise_error
|
86
|
-
verify_called.should be_true
|
87
|
-
|
88
|
-
@space.doubles[@object][@method_name].should be_nil
|
89
|
-
@object.methods.should_not include("__rr__#{@method_name}")
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe Space, "#verify_ordered_scenario", :shared => true do
|
94
|
-
it_should_behave_like "RR::Space"
|
95
|
-
|
96
|
-
before do
|
97
|
-
@space = Space.new
|
98
|
-
@object = Object.new
|
99
|
-
@method_name = :foobar
|
100
|
-
@double = @space.double(@object, @method_name)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "raises an error when Scenario is NonTerminal" do
|
104
|
-
scenario = @space.scenario(@double)
|
105
|
-
@space.register_ordered_scenario(scenario)
|
106
|
-
|
107
|
-
scenario.any_number_of_times
|
108
|
-
scenario.should_not be_terminal
|
109
|
-
|
110
|
-
proc do
|
111
|
-
@space.verify_ordered_scenario(scenario)
|
112
|
-
end.should raise_error(
|
113
|
-
Errors::ScenarioOrderError,
|
114
|
-
"Ordered Scenarios cannot have a NonTerminal TimesCalledExpectation"
|
115
|
-
)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe Space, "#verify_ordered_scenario where the passed in scenario is at the front of the queue" do
|
120
|
-
it_should_behave_like "RR::Space#verify_ordered_scenario"
|
121
|
-
|
122
|
-
it "keeps the scenario when times called is not verified" do
|
123
|
-
scenario = @space.scenario(@double)
|
124
|
-
@space.register_ordered_scenario(scenario)
|
125
|
-
|
126
|
-
scenario.twice
|
127
|
-
scenario.should be_attempt
|
128
|
-
|
129
|
-
@space.verify_ordered_scenario(scenario)
|
130
|
-
@space.ordered_scenarios.should include(scenario)
|
131
|
-
end
|
132
|
-
|
133
|
-
it "removes the scenario when times called expectation should no longer be attempted" do
|
134
|
-
scenario = @space.scenario(@double)
|
135
|
-
@space.register_ordered_scenario(scenario)
|
136
|
-
|
137
|
-
scenario.with(1).once
|
138
|
-
@object.foobar(1)
|
139
|
-
scenario.should_not be_attempt
|
140
|
-
|
141
|
-
@space.verify_ordered_scenario(scenario)
|
142
|
-
@space.ordered_scenarios.should_not include(scenario)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
describe Space, "#verify_ordered_scenario where the passed in scenario is not at the front of the queue" do
|
147
|
-
it_should_behave_like "RR::Space#verify_ordered_scenario"
|
148
|
-
|
149
|
-
it "raises error" do
|
150
|
-
first_scenario = scenario
|
151
|
-
second_scenario = scenario
|
152
|
-
|
153
|
-
proc do
|
154
|
-
@space.verify_ordered_scenario(second_scenario)
|
155
|
-
end.should raise_error(
|
156
|
-
Errors::ScenarioOrderError,
|
157
|
-
"foobar() called out of order in list\n" <<
|
158
|
-
"- foobar()\n" <<
|
159
|
-
"- foobar()"
|
160
|
-
)
|
161
|
-
end
|
162
|
-
|
163
|
-
def scenario
|
164
|
-
scenario_definition = @space.scenario(@double).once
|
165
|
-
@space.register_ordered_scenario(scenario_definition.scenario)
|
166
|
-
scenario_definition.scenario
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require "examples/example_helper"
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module TimesCalledMatchers
|
5
|
-
describe AnyTimesMatcher, :shared => true do
|
6
|
-
before do
|
7
|
-
@matcher = AnyTimesMatcher.new
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe TimesCalledMatcher, ".create when passed a AnyTimesMatcher" do
|
12
|
-
it "returns the passed in argument" do
|
13
|
-
matcher = AnyTimesMatcher.new
|
14
|
-
TimesCalledMatcher.create(matcher).should === matcher
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe AnyTimesMatcher, "#possible_match?" do
|
19
|
-
it_should_behave_like "RR::TimesCalledMatchers::AnyTimesMatcher"
|
20
|
-
|
21
|
-
it "always returns true" do
|
22
|
-
@matcher.should be_possible_match(0)
|
23
|
-
@matcher.should be_possible_match(99999)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe AnyTimesMatcher, "#matches?" do
|
28
|
-
it_should_behave_like "RR::TimesCalledMatchers::AnyTimesMatcher"
|
29
|
-
|
30
|
-
it "always returns true" do
|
31
|
-
@matcher.should be_matches(0)
|
32
|
-
@matcher.should be_matches(99999)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe AnyTimesMatcher, "#attempt?" do
|
37
|
-
it_should_behave_like "RR::TimesCalledMatchers::AnyTimesMatcher"
|
38
|
-
|
39
|
-
it "always returns true" do
|
40
|
-
@matcher.should be_attempt(0)
|
41
|
-
@matcher.should be_attempt(99999)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe AnyTimesMatcher, "#terminal?" do
|
46
|
-
it_should_behave_like "RR::TimesCalledMatchers::AnyTimesMatcher"
|
47
|
-
|
48
|
-
it "returns false" do
|
49
|
-
@matcher.should_not be_terminal
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe AnyTimesMatcher, "#error_message" do
|
54
|
-
it_should_behave_like "RR::TimesCalledMatchers::AnyTimesMatcher"
|
55
|
-
|
56
|
-
it "has an error message" do
|
57
|
-
@matcher.error_message(2).should == (
|
58
|
-
"Called 2 times.\nExpected any number of times."
|
59
|
-
)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require "examples/example_helper"
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module TimesCalledMatchers
|
5
|
-
describe AtLeastMatcher, :shared => true do
|
6
|
-
before do
|
7
|
-
@times = 3
|
8
|
-
@matcher = AtLeastMatcher.new(@times)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe TimesCalledMatcher, ".create when passed a AtLeastMatcher" do
|
13
|
-
it "returns the passed in argument" do
|
14
|
-
matcher = AtLeastMatcher.new(5)
|
15
|
-
TimesCalledMatcher.create(matcher).should === matcher
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe AtLeastMatcher, "#possible_match?" do
|
20
|
-
it_should_behave_like "RR::TimesCalledMatchers::AtLeastMatcher"
|
21
|
-
|
22
|
-
it "always returns true" do
|
23
|
-
@matcher.should be_possible_match(99999)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe AtLeastMatcher, "#matches?" do
|
28
|
-
it_should_behave_like "RR::TimesCalledMatchers::AtLeastMatcher"
|
29
|
-
|
30
|
-
it "returns false when times_called less than times" do
|
31
|
-
@matcher.should_not be_matches(2)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "returns true when times_called == times" do
|
35
|
-
@matcher.should be_matches(3)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "returns true when times_called > times" do
|
39
|
-
@matcher.should be_matches(4)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe AtLeastMatcher, "#attempt?" do
|
44
|
-
it_should_behave_like "RR::TimesCalledMatchers::AtLeastMatcher"
|
45
|
-
|
46
|
-
it "always returns true" do
|
47
|
-
@matcher.should be_attempt(1)
|
48
|
-
@matcher.should be_attempt(100000)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe AnyTimesMatcher, "#terminal?" do
|
53
|
-
it_should_behave_like "RR::TimesCalledMatchers::AtLeastMatcher"
|
54
|
-
|
55
|
-
it "returns false" do
|
56
|
-
@matcher.should_not be_terminal
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe AtLeastMatcher, "#error_message" do
|
61
|
-
it_should_behave_like "RR::TimesCalledMatchers::AtLeastMatcher"
|
62
|
-
|
63
|
-
it "has an error message" do
|
64
|
-
@matcher.error_message(2).should == (
|
65
|
-
"Called 2 times.\nExpected at least 3 times."
|
66
|
-
)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|