rr 0.4.10 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +14 -0
- data/README.rdoc +67 -13
- data/Rakefile +1 -1
- data/lib/rr.rb +29 -9
- data/lib/rr/adapters/rr_methods.rb +38 -158
- data/lib/rr/double.rb +46 -41
- data/lib/rr/double_definitions/child_double_definition_creator.rb +23 -0
- data/lib/rr/double_definitions/double_definition.rb +212 -0
- data/lib/rr/double_definitions/double_definition_creator.rb +153 -0
- data/lib/rr/double_definitions/double_definition_creator_proxy.rb +25 -0
- data/lib/rr/double_definitions/strategies/implementation/implementation_strategy.rb +15 -0
- data/lib/rr/double_definitions/strategies/implementation/proxy.rb +62 -0
- data/lib/rr/double_definitions/strategies/implementation/reimplementation.rb +14 -0
- data/lib/rr/double_definitions/strategies/scope/instance.rb +15 -0
- data/lib/rr/double_definitions/strategies/scope/instance_of_class.rb +43 -0
- data/lib/rr/double_definitions/strategies/scope/scope_strategy.rb +15 -0
- data/lib/rr/double_definitions/strategies/strategy.rb +70 -0
- data/lib/rr/double_definitions/strategies/verification/dont_allow.rb +34 -0
- data/lib/rr/double_definitions/strategies/verification/mock.rb +44 -0
- data/lib/rr/double_definitions/strategies/verification/stub.rb +45 -0
- data/lib/rr/double_definitions/strategies/verification/verification_strategy.rb +15 -0
- data/lib/rr/double_injection.rb +21 -15
- data/lib/rr/expectations/argument_equality_expectation.rb +2 -1
- data/lib/rr/space.rb +23 -22
- data/lib/rr/wildcard_matchers/hash_including.rb +29 -0
- data/lib/rr/wildcard_matchers/satisfy.rb +26 -0
- data/spec/high_level_spec.rb +111 -64
- data/spec/rr/adapters/rr_methods_argument_matcher_spec.rb +1 -1
- data/spec/rr/adapters/rr_methods_creator_spec.rb +99 -315
- data/spec/rr/adapters/rr_methods_space_spec.rb +90 -109
- data/spec/rr/adapters/rr_methods_spec_helper.rb +1 -1
- data/spec/rr/adapters/rr_methods_times_matcher_spec.rb +1 -1
- data/spec/rr/double_definitions/child_double_definition_creator_spec.rb +103 -0
- data/spec/rr/double_definitions/double_definition_creator_proxy_spec.rb +83 -0
- data/spec/rr/double_definitions/double_definition_creator_spec.rb +495 -0
- data/spec/rr/double_definitions/double_definition_spec.rb +1116 -0
- data/spec/rr/double_injection/double_injection_bind_spec.rb +111 -0
- data/spec/rr/double_injection/double_injection_dispatching_spec.rb +245 -0
- data/spec/rr/{double → double_injection}/double_injection_has_original_method_spec.rb +9 -9
- data/spec/rr/double_injection/double_injection_reset_spec.rb +90 -0
- data/spec/rr/double_injection/double_injection_spec.rb +77 -0
- data/spec/rr/double_injection/double_injection_verify_spec.rb +29 -0
- data/spec/rr/double_spec.rb +156 -136
- data/spec/rr/errors/rr_error_spec.rb +1 -1
- data/spec/rr/expectations/any_argument_expectation_spec.rb +1 -1
- data/spec/rr/expectations/anything_argument_equality_expectation_spec.rb +6 -30
- data/spec/rr/expectations/argument_equality_expectation_spec.rb +35 -18
- data/spec/rr/expectations/boolean_argument_equality_expectation_spec.rb +22 -41
- data/spec/rr/expectations/hash_including_argument_equality_expectation_spec.rb +82 -0
- data/spec/rr/expectations/hash_including_spec.rb +17 -0
- data/spec/rr/expectations/satisfy_argument_equality_expectation_spec.rb +59 -0
- data/spec/rr/expectations/satisfy_spec.rb +14 -0
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_any_times_spec.rb +30 -28
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb +55 -54
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_most_spec.rb +49 -48
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +9 -7
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_integer_spec.rb +77 -76
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb +58 -57
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb +59 -58
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_spec.rb +25 -24
- data/spec/rr/rspec/rspec_adapter_spec.rb +12 -11
- data/spec/rr/rspec/rspec_backtrace_tweaking_spec.rb +10 -8
- data/spec/rr/rspec/rspec_usage_spec.rb +1 -1
- data/spec/rr/space/hash_with_object_id_key_spec.rb +1 -1
- data/spec/rr/space/space_spec.rb +330 -192
- data/spec/rr/test_unit/test_helper.rb +1 -2
- data/spec/rr/test_unit/test_unit_backtrace_test.rb +1 -2
- data/spec/rr/test_unit/test_unit_integration_test.rb +1 -2
- data/spec/rr/times_called_matchers/any_times_matcher_spec.rb +1 -1
- data/spec/rr/times_called_matchers/at_least_matcher_spec.rb +1 -1
- data/spec/rr/times_called_matchers/at_most_matcher_spec.rb +1 -1
- data/spec/rr/times_called_matchers/integer_matcher_spec.rb +1 -1
- data/spec/rr/times_called_matchers/proc_matcher_spec.rb +1 -1
- data/spec/rr/times_called_matchers/range_matcher_spec.rb +1 -1
- data/spec/rr/times_called_matchers/times_called_matcher_spec.rb +1 -1
- data/spec/rr/wildcard_matchers/anything_spec.rb +24 -0
- data/spec/rr/wildcard_matchers/boolean_spec.rb +36 -0
- data/spec/rr/wildcard_matchers/duck_type_spec.rb +52 -0
- data/spec/rr/wildcard_matchers/is_a_spec.rb +32 -0
- data/spec/rr/wildcard_matchers/numeric_spec.rb +32 -0
- data/spec/rr/wildcard_matchers/range_spec.rb +35 -0
- data/spec/rr/wildcard_matchers/regexp_spec.rb +43 -0
- data/spec/rr_spec.rb +28 -0
- data/spec/spec_helper.rb +84 -0
- metadata +43 -29
- data/lib/rr/double_creator.rb +0 -271
- data/lib/rr/double_definition.rb +0 -179
- data/lib/rr/double_definition_builder.rb +0 -44
- data/lib/rr/double_definition_creator.rb +0 -156
- data/lib/rr/double_definition_creator_proxy.rb +0 -20
- data/spec/rr/double/double_injection_bind_spec.rb +0 -105
- data/spec/rr/double/double_injection_dispatching_spec.rb +0 -228
- data/spec/rr/double/double_injection_reset_spec.rb +0 -86
- data/spec/rr/double/double_injection_spec.rb +0 -72
- data/spec/rr/double/double_injection_verify_spec.rb +0 -24
- data/spec/rr/double_definition_creator_proxy_spec.rb +0 -85
- data/spec/rr/double_definition_creator_spec.rb +0 -496
- data/spec/rr/double_definition_spec.rb +0 -815
- data/spec/rr/expectations/anything_spec.rb +0 -14
- data/spec/rr/expectations/boolean_spec.rb +0 -14
- data/spec/rr/expectations/duck_type_argument_equality_expectation_spec.rb +0 -71
- data/spec/rr/expectations/duck_type_spec.rb +0 -14
- data/spec/rr/expectations/is_a_argument_equality_expectation_spec.rb +0 -51
- data/spec/rr/expectations/is_a_spec.rb +0 -14
- data/spec/rr/expectations/numeric_argument_equality_expectation_spec.rb +0 -47
- data/spec/rr/expectations/numeric_spec.rb +0 -14
- data/spec/rr/expectations/range_argument_equality_expectation_spec.rb +0 -59
- data/spec/rr/expectations/range_spec.rb +0 -10
- data/spec/rr/expectations/regexp_argument_equality_expectation_spec.rb +0 -72
- data/spec/rr/expectations/regexp_spec.rb +0 -10
@@ -1,38 +1,14 @@
|
|
1
|
-
require "
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
2
|
|
3
3
|
module RR
|
4
4
|
module Expectations
|
5
|
-
describe ArgumentEqualityExpectation
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
describe "#exact_match? with anything argument" do
|
12
|
-
it "returns true when passed in an Anything module" do
|
13
|
-
expectation.should be_exact_match(WildcardMatchers::Anything.new)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "returns false otherwise" do
|
17
|
-
expectation.should_not be_exact_match("hello")
|
18
|
-
expectation.should_not be_exact_match(:hello)
|
19
|
-
expectation.should_not be_exact_match(1)
|
20
|
-
expectation.should_not be_exact_match(nil)
|
21
|
-
expectation.should_not be_exact_match()
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "#wildcard_match? with is_a String argument" do
|
26
|
-
it "returns true when passed correct number of arguments" do
|
27
|
-
expectation.should be_wildcard_match(Object.new)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns false when not passed correct number of arguments" do
|
31
|
-
expectation.should_not be_wildcard_match()
|
32
|
-
expectation.should_not be_wildcard_match(Object.new, Object.new)
|
5
|
+
describe ArgumentEqualityExpectation do
|
6
|
+
context "when matching anything" do
|
7
|
+
attr_reader :expectation
|
8
|
+
before do
|
9
|
+
@expectation = ArgumentEqualityExpectation.new(anything)
|
33
10
|
end
|
34
11
|
end
|
35
12
|
end
|
36
|
-
|
37
13
|
end
|
38
14
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
2
|
|
3
3
|
module RR
|
4
4
|
module Expectations
|
@@ -28,28 +28,46 @@ module RR
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "#exact_match?" do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
context "when all arguments exactly match" do
|
32
|
+
it "returns true" do
|
33
|
+
expectation.should be_exact_match(1, 2, 3)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when all arguments do not exactly match" do
|
38
|
+
it "returns false" do
|
39
|
+
expectation.should_not be_exact_match(1, 2)
|
40
|
+
expectation.should_not be_exact_match(1)
|
41
|
+
expectation.should_not be_exact_match()
|
42
|
+
expectation.should_not be_exact_match("does not match")
|
43
|
+
end
|
37
44
|
end
|
38
45
|
end
|
39
46
|
|
40
47
|
describe "#wildcard_match?" do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
48
|
+
context "when not an exact match" do
|
49
|
+
it "returns false" do
|
50
|
+
expectation = ArgumentEqualityExpectation.new(1)
|
51
|
+
expectation.should_not be_wildcard_match(1, 2, 3)
|
52
|
+
expectation.should_not be_wildcard_match("whatever")
|
53
|
+
expectation.should_not be_wildcard_match("whatever", "else")
|
54
|
+
end
|
46
55
|
end
|
47
56
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
57
|
+
context "when an exact match" do
|
58
|
+
it "returns true" do
|
59
|
+
expectation = ArgumentEqualityExpectation.new(1, 2)
|
60
|
+
expectation.should be_wildcard_match(1, 2)
|
61
|
+
expectation.should_not be_wildcard_match(1)
|
62
|
+
expectation.should_not be_wildcard_match("whatever", "else")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when not passed correct number of arguments" do
|
67
|
+
it "returns false" do
|
68
|
+
expectation.should_not be_wildcard_match()
|
69
|
+
expectation.should_not be_wildcard_match(Object.new, Object.new)
|
70
|
+
end
|
53
71
|
end
|
54
72
|
end
|
55
73
|
|
@@ -113,6 +131,5 @@ module RR
|
|
113
131
|
|
114
132
|
end
|
115
133
|
end
|
116
|
-
|
117
134
|
end
|
118
135
|
end
|
@@ -1,53 +1,34 @@
|
|
1
|
-
require "
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
2
|
|
3
3
|
module RR
|
4
4
|
module Expectations
|
5
|
-
describe ArgumentEqualityExpectation
|
6
|
-
|
7
|
-
|
8
|
-
before do
|
9
|
-
@expectation = ArgumentEqualityExpectation.new(boolean)
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#exact_match?" do
|
13
|
-
it "returns true when passed in an IsA module" do
|
14
|
-
expectation.should be_exact_match(WildcardMatchers::Boolean.new)
|
15
|
-
end
|
5
|
+
describe ArgumentEqualityExpectation do
|
6
|
+
context "with a boolean matcher" do
|
7
|
+
attr_reader :expectation
|
16
8
|
|
17
|
-
it "returns false otherwise" do
|
18
|
-
expectation.should_not be_exact_match("hello")
|
19
|
-
expectation.should_not be_exact_match(:hello)
|
20
|
-
expectation.should_not be_exact_match(1)
|
21
|
-
expectation.should_not be_exact_match(nil)
|
22
|
-
expectation.should_not be_exact_match(true)
|
23
|
-
expectation.should_not be_exact_match()
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#wildcard_match?" do
|
28
9
|
before do
|
29
|
-
expectation = ArgumentEqualityExpectation.new(boolean)
|
10
|
+
@expectation = ArgumentEqualityExpectation.new(boolean)
|
30
11
|
end
|
31
12
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
13
|
+
describe "#wildcard_match?" do
|
14
|
+
before do
|
15
|
+
expectation = ArgumentEqualityExpectation.new(boolean)
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when passed a Boolean" do
|
19
|
+
it "returns true" do
|
20
|
+
expectation.should be_wildcard_match(true)
|
21
|
+
expectation.should be_wildcard_match(false)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when not passed a Boolean" do
|
26
|
+
it "returns false" do
|
27
|
+
expectation.should_not be_wildcard_match(:not_a_boolean)
|
28
|
+
end
|
29
|
+
end
|
48
30
|
end
|
49
31
|
end
|
50
32
|
end
|
51
|
-
|
52
33
|
end
|
53
34
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
+
|
3
|
+
module RR
|
4
|
+
module Expectations
|
5
|
+
describe ArgumentEqualityExpectation, "with HashIncluding argument" do
|
6
|
+
attr_reader :expectation, :expected_hash
|
7
|
+
|
8
|
+
before do
|
9
|
+
@expected_hash = {:texas => "Austin", :maine => "Augusta"}
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#exact_match?" do
|
13
|
+
before do
|
14
|
+
@expectation = ArgumentEqualityExpectation.new(hash_including(expected_hash))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns true when passed in a HashIncluding matcher with the same hash" do
|
18
|
+
expectation.should be_exact_match(WildcardMatchers::HashIncluding.new(expected_hash))
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns false when passed in a HashIncluding matcher with a different argument list" do
|
22
|
+
expectation.should_not be_exact_match(WildcardMatchers::HashIncluding.new(:foo => 1))
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns false otherwise" do
|
26
|
+
expectation.should_not be_exact_match("hello")
|
27
|
+
expectation.should_not be_exact_match(:hello)
|
28
|
+
expectation.should_not be_exact_match(1)
|
29
|
+
expectation.should_not be_exact_match(nil)
|
30
|
+
expectation.should_not be_exact_match(true)
|
31
|
+
expectation.should_not be_exact_match()
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#wildcard_match?" do
|
36
|
+
before do
|
37
|
+
@expectation = ArgumentEqualityExpectation.new(hash_including(expected_hash))
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns true when hash contains same key/values as the expectation" do
|
41
|
+
expectation.should be_wildcard_match(expected_hash)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns true when hash contains at least expectation's key/values" do
|
45
|
+
expectation.should be_wildcard_match(expected_hash.merge(:oregon => "Salem"))
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns true when passed the same hash, even after the original is modified" do
|
49
|
+
original_expected_hash = expected_hash.clone
|
50
|
+
expected_hash[:texas] = nil
|
51
|
+
expectation.should be_wildcard_match(original_expected_hash)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns true even if one of the expectation's values is nil" do
|
55
|
+
expectation = ArgumentEqualityExpectation.new(hash_including(:foo => nil))
|
56
|
+
expectation.should be_wildcard_match({:foo => nil})
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns false when hash matches only some required key/values" do
|
60
|
+
expectation.should_not be_wildcard_match({:texas => "Austin"})
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns false when hash matches all the keys but not all the values" do
|
64
|
+
expectation.should_not be_wildcard_match({:texas => "Austin", :maine => "Portland"})
|
65
|
+
end
|
66
|
+
|
67
|
+
it "returns false when passed a hash that matches all values but not all keys" do
|
68
|
+
expectation.should_not be_wildcard_match({:texas => "Austin", :georgia => "Augusta"})
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns true when an exact match" do
|
72
|
+
expectation.should be_wildcard_match(hash_including(expected_hash))
|
73
|
+
end
|
74
|
+
|
75
|
+
it "returns false when not passed correct number of arguments" do
|
76
|
+
expectation.should_not be_wildcard_match()
|
77
|
+
expectation.should_not be_wildcard_match(:a, :b)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
+
|
3
|
+
module RR
|
4
|
+
module WildcardMatchers
|
5
|
+
describe HashIncluding do
|
6
|
+
describe "#inspect" do
|
7
|
+
it "returns hash_including with expected key/values" do
|
8
|
+
expected_hash = {:foo => "bar", :baz => "qux"}
|
9
|
+
matcher = HashIncluding.new(expected_hash)
|
10
|
+
matcher.inspect.should include("hash_including(")
|
11
|
+
matcher.inspect.should include(':foo=>"bar"')
|
12
|
+
matcher.inspect.should include(':baz=>"qux"')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
+
|
3
|
+
module RR
|
4
|
+
module Expectations
|
5
|
+
describe ArgumentEqualityExpectation, "with Satisfy argument" do
|
6
|
+
attr_reader :expectation, :expectation_proc, :expected_value, :satisfy_matcher
|
7
|
+
|
8
|
+
before do
|
9
|
+
@expected_value = :foo
|
10
|
+
@expectation_proc = lambda {|argument| argument == expected_value}
|
11
|
+
@satisfy_matcher = satisfy(&expectation_proc)
|
12
|
+
@expectation = ArgumentEqualityExpectation.new(satisfy_matcher)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#exact_match?" do
|
16
|
+
before do
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns true when passed a Satisfy matcher with the same proc" do
|
20
|
+
expectation.should be_exact_match(WildcardMatchers::Satisfy.new(expectation_proc))
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns false when passed a Satisfy matcher with another proc" do
|
24
|
+
expectation.should_not be_exact_match(WildcardMatchers::Satisfy.new(lambda {}))
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns false otherwise" do
|
28
|
+
expectation.should_not be_exact_match("hello")
|
29
|
+
expectation.should_not be_exact_match(:hello)
|
30
|
+
expectation.should_not be_exact_match(1)
|
31
|
+
expectation.should_not be_exact_match(nil)
|
32
|
+
expectation.should_not be_exact_match(true)
|
33
|
+
expectation.should_not be_exact_match()
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#wildcard_match?" do
|
38
|
+
it "returns true when the proc returns a truthy value" do
|
39
|
+
(!!expectation_proc.call(expected_value)).should be_true
|
40
|
+
expectation.should be_wildcard_match(expected_value)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns false when the proc returns a falsey value" do
|
44
|
+
(!!expectation_proc.call(:bar)).should be_false
|
45
|
+
expectation.should_not be_wildcard_match(:bar)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns true when an exact match" do
|
49
|
+
expectation.should be_wildcard_match(satisfy_matcher)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns false when not passed correct number of arguments" do
|
53
|
+
expectation.should_not be_wildcard_match()
|
54
|
+
expectation.should_not be_wildcard_match(:a, :b)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
+
|
3
|
+
module RR
|
4
|
+
module WildcardMatchers
|
5
|
+
describe Satisfy do
|
6
|
+
describe "#inspect" do
|
7
|
+
it "returns satisfy string" do
|
8
|
+
matcher = Satisfy.new(lambda {})
|
9
|
+
matcher.inspect.should == "satisfy {block}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/rr/expectations/times_called_expectation/times_called_expectation_any_times_spec.rb
CHANGED
@@ -1,41 +1,43 @@
|
|
1
|
-
require "
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../../spec_helper")
|
2
2
|
|
3
3
|
module RR
|
4
4
|
module Expectations
|
5
|
-
describe TimesCalledExpectation
|
6
|
-
|
7
|
-
|
5
|
+
describe TimesCalledExpectation do
|
6
|
+
context "when using an AnyTimesMatcher" do
|
7
|
+
it_should_behave_like "RR::Expectations::TimesCalledExpectation"
|
8
|
+
attr_reader :at_least, :expectation
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#verify!" do
|
15
|
-
it "always passes" do
|
16
|
-
expectation.verify!
|
17
|
-
10.times {expectation.attempt}
|
18
|
-
expectation.verify!
|
10
|
+
before do
|
11
|
+
@at_least = TimesCalledMatchers::AnyTimesMatcher.new
|
12
|
+
@expectation = TimesCalledExpectation.new(double, at_least)
|
19
13
|
end
|
20
|
-
end
|
21
14
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
15
|
+
describe "#verify!" do
|
16
|
+
it "always passes" do
|
17
|
+
expectation.verify!
|
18
|
+
10.times {expectation.attempt}
|
19
|
+
expectation.verify!
|
20
|
+
end
|
27
21
|
end
|
28
|
-
end
|
29
22
|
|
30
|
-
|
31
|
-
|
32
|
-
|
23
|
+
describe "#attempt?" do
|
24
|
+
it "always returns true" do
|
25
|
+
expectation.should be_attempt
|
26
|
+
10.times {expectation.attempt}
|
27
|
+
expectation.should be_attempt
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#attempt!" do
|
32
|
+
it "always passes" do
|
33
|
+
10.times {expectation.attempt}
|
34
|
+
end
|
33
35
|
end
|
34
|
-
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
describe "#terminal?" do
|
38
|
+
it "returns false" do
|
39
|
+
expectation.should_not be_terminal
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|