rr 0.3.11 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. data/CHANGES +8 -3
  2. data/README +130 -39
  3. data/Rakefile +6 -5
  4. data/lib/rr.rb +8 -8
  5. data/lib/rr/adapters/rr_methods.rb +228 -0
  6. data/lib/rr/adapters/rspec.rb +1 -1
  7. data/lib/rr/adapters/test_unit.rb +1 -1
  8. data/lib/rr/double.rb +294 -89
  9. data/lib/rr/{scenario_creator.rb → double_creator.rb} +65 -66
  10. data/lib/rr/{scenario_definition.rb → double_definition.rb} +36 -36
  11. data/lib/rr/{scenario_definition_builder.rb → double_definition_builder.rb} +3 -3
  12. data/lib/rr/double_insertion.rb +132 -0
  13. data/lib/rr/{scenario_matches.rb → double_matches.rb} +2 -2
  14. data/lib/rr/{scenario_method_proxy.rb → double_method_proxy.rb} +2 -2
  15. data/lib/rr/errors/argument_equality_error.rb +3 -3
  16. data/lib/rr/errors/rr_error.rb +13 -13
  17. data/lib/rr/errors/scenario_definition_error.rb +3 -3
  18. data/lib/rr/errors/scenario_not_found_error.rb +3 -3
  19. data/lib/rr/errors/scenario_order_error.rb +3 -3
  20. data/lib/rr/errors/times_called_error.rb +3 -3
  21. data/lib/rr/expectations/any_argument_expectation.rb +1 -1
  22. data/lib/rr/expectations/argument_equality_expectation.rb +1 -1
  23. data/lib/rr/expectations/times_called_expectation.rb +1 -1
  24. data/lib/rr/hash_with_object_id_key.rb +1 -1
  25. data/lib/rr/space.rb +40 -40
  26. data/lib/rr/times_called_matchers/any_times_matcher.rb +13 -13
  27. data/lib/rr/times_called_matchers/at_least_matcher.rb +11 -11
  28. data/lib/rr/times_called_matchers/at_most_matcher.rb +16 -16
  29. data/lib/rr/times_called_matchers/integer_matcher.rb +13 -13
  30. data/lib/rr/times_called_matchers/non_terminal.rb +21 -21
  31. data/lib/rr/times_called_matchers/proc_matcher.rb +7 -7
  32. data/lib/rr/times_called_matchers/range_matcher.rb +14 -14
  33. data/lib/rr/times_called_matchers/terminal.rb +16 -16
  34. data/lib/rr/times_called_matchers/times_called_matcher.rb +32 -32
  35. data/spec/core_spec_suite.rb +18 -0
  36. data/{examples → spec}/environment_fixture_setup.rb +0 -1
  37. data/{examples/high_level_example.rb → spec/high_level_spec.rb} +11 -11
  38. data/spec/rr/adapters/rr_methods_argument_matcher_spec.rb +67 -0
  39. data/spec/rr/adapters/rr_methods_creator_spec.rb +365 -0
  40. data/spec/rr/adapters/rr_methods_space_spec.rb +134 -0
  41. data/spec/rr/adapters/rr_methods_spec_helper.rb +11 -0
  42. data/{examples/rr/extensions/instance_methods_times_matcher_example.rb → spec/rr/adapters/rr_methods_times_matcher_spec.rb} +4 -4
  43. data/spec/rr/double/double_insertion_bind_spec.rb +78 -0
  44. data/spec/rr/double/double_insertion_dispatching_spec.rb +221 -0
  45. data/spec/rr/double/double_insertion_has_original_method_spec.rb +56 -0
  46. data/spec/rr/double/double_insertion_register_scenario_spec.rb +24 -0
  47. data/spec/rr/double/double_insertion_reset_spec.rb +89 -0
  48. data/spec/rr/double/double_insertion_spec.rb +66 -0
  49. data/spec/rr/double/double_insertion_verify_spec.rb +23 -0
  50. data/spec/rr/double_creator_spec.rb +454 -0
  51. data/{examples/rr/scenario_definition_example.rb → spec/rr/double_definition_spec.rb} +143 -143
  52. data/spec/rr/double_method_proxy_spec.rb +71 -0
  53. data/spec/rr/double_spec.rb +654 -0
  54. data/spec/rr/errors/rr_error_spec.rb +65 -0
  55. data/spec/rr/expectations/any_argument_expectation_spec.rb +47 -0
  56. data/spec/rr/expectations/anything_argument_equality_expectation_spec.rb +38 -0
  57. data/spec/rr/expectations/argument_equality_expectation_spec.rb +58 -0
  58. data/spec/rr/expectations/boolean_argument_equality_expectation_spec.rb +53 -0
  59. data/spec/rr/expectations/duck_type_argument_equality_expectation_spec.rb +71 -0
  60. data/spec/rr/expectations/is_a_argument_equality_expectation_spec.rb +51 -0
  61. data/spec/rr/expectations/numeric_argument_equality_expectation_spec.rb +47 -0
  62. data/spec/rr/expectations/range_argument_equality_expectation_spec.rb +59 -0
  63. data/spec/rr/expectations/regexp_argument_equality_expectation_spec.rb +72 -0
  64. data/spec/rr/expectations/times_called_expectation/times_called_expectation_any_times_spec.rb +43 -0
  65. data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb +67 -0
  66. data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_most_spec.rb +71 -0
  67. data/spec/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +21 -0
  68. data/spec/rr/expectations/times_called_expectation/times_called_expectation_integer_spec.rb +103 -0
  69. data/spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb +79 -0
  70. data/spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb +81 -0
  71. data/spec/rr/expectations/times_called_expectation/times_called_expectation_spec.rb +40 -0
  72. data/spec/rr/rspec/rspec_adapter_spec.rb +65 -0
  73. data/spec/rr/rspec/rspec_backtrace_tweaking_spec.rb +52 -0
  74. data/spec/rr/rspec/rspec_usage_spec.rb +67 -0
  75. data/spec/rr/space/hash_with_object_id_key_spec.rb +88 -0
  76. data/spec/rr/space/space_create_spec.rb +278 -0
  77. data/spec/rr/space/space_helper.rb +7 -0
  78. data/spec/rr/space/space_register_spec.rb +32 -0
  79. data/spec/rr/space/space_reset_spec.rb +131 -0
  80. data/spec/rr/space/space_spec.rb +32 -0
  81. data/spec/rr/space/space_verify_spec.rb +181 -0
  82. data/{examples → spec}/rr/test_unit/test_helper.rb +1 -1
  83. data/{examples → spec}/rr/test_unit/test_unit_backtrace_test.rb +0 -0
  84. data/{examples → spec}/rr/test_unit/test_unit_integration_test.rb +4 -4
  85. data/spec/rr/times_called_matchers/any_times_matcher_spec.rb +47 -0
  86. data/spec/rr/times_called_matchers/at_least_matcher_spec.rb +55 -0
  87. data/spec/rr/times_called_matchers/at_most_matcher_spec.rb +70 -0
  88. data/spec/rr/times_called_matchers/integer_matcher_spec.rb +70 -0
  89. data/spec/rr/times_called_matchers/proc_matcher_spec.rb +55 -0
  90. data/spec/rr/times_called_matchers/range_matcher_spec.rb +76 -0
  91. data/spec/rr/times_called_matchers/times_called_matcher_spec.rb +118 -0
  92. data/spec/rspec_spec_suite.rb +16 -0
  93. data/spec/spec_helper.rb +9 -0
  94. data/{examples/example_suite.rb → spec/spec_suite.rb} +3 -3
  95. data/{examples/test_unit_example_suite.rb → spec/test_unit_spec_suite.rb} +0 -0
  96. metadata +93 -93
  97. data/examples/core_example_suite.rb +0 -31
  98. data/examples/example_helper.rb +0 -9
  99. data/examples/rr/double/double_bind_example.rb +0 -70
  100. data/examples/rr/double/double_dispatching_example.rb +0 -236
  101. data/examples/rr/double/double_example.rb +0 -66
  102. data/examples/rr/double/double_has_original_method_example.rb +0 -56
  103. data/examples/rr/double/double_register_scenario_example.rb +0 -24
  104. data/examples/rr/double/double_reset_example.rb +0 -89
  105. data/examples/rr/double/double_verify_example.rb +0 -23
  106. data/examples/rr/errors/rr_error_example.rb +0 -65
  107. data/examples/rr/expectations/any_argument_expectation_example.rb +0 -52
  108. data/examples/rr/expectations/anything_argument_equality_expectation_example.rb +0 -38
  109. data/examples/rr/expectations/argument_equality_expectation_example.rb +0 -62
  110. data/examples/rr/expectations/boolean_argument_equality_expectation_example.rb +0 -48
  111. data/examples/rr/expectations/duck_type_argument_equality_expectation_example.rb +0 -67
  112. data/examples/rr/expectations/is_a_argument_equality_expectation_example.rb +0 -50
  113. data/examples/rr/expectations/numeric_argument_equality_expectation_example.rb +0 -46
  114. data/examples/rr/expectations/range_argument_equality_expectation_example.rb +0 -59
  115. data/examples/rr/expectations/regexp_argument_equality_expectation_example.rb +0 -67
  116. data/examples/rr/expectations/times_called_expectation/times_called_expectation_any_times_example.rb +0 -50
  117. data/examples/rr/expectations/times_called_expectation/times_called_expectation_at_least_example.rb +0 -73
  118. data/examples/rr/expectations/times_called_expectation/times_called_expectation_at_most_example.rb +0 -77
  119. data/examples/rr/expectations/times_called_expectation/times_called_expectation_example.rb +0 -42
  120. data/examples/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +0 -20
  121. data/examples/rr/expectations/times_called_expectation/times_called_expectation_integer_example.rb +0 -111
  122. data/examples/rr/expectations/times_called_expectation/times_called_expectation_proc_example.rb +0 -88
  123. data/examples/rr/expectations/times_called_expectation/times_called_expectation_range_example.rb +0 -90
  124. data/examples/rr/extensions/instance_methods_argument_matcher_example.rb +0 -65
  125. data/examples/rr/extensions/instance_methods_creator_example.rb +0 -363
  126. data/examples/rr/extensions/instance_methods_example_helper.rb +0 -11
  127. data/examples/rr/extensions/instance_methods_space_example.rb +0 -122
  128. data/examples/rr/rspec/rspec_adapter_example.rb +0 -63
  129. data/examples/rr/rspec/rspec_backtrace_tweaking_example.rb +0 -36
  130. data/examples/rr/rspec/rspec_usage_example.rb +0 -65
  131. data/examples/rr/scenario_creator_example.rb +0 -459
  132. data/examples/rr/scenario_example.rb +0 -701
  133. data/examples/rr/scenario_method_proxy_example.rb +0 -71
  134. data/examples/rr/space/hash_with_object_id_key_example.rb +0 -86
  135. data/examples/rr/space/space_create_example.rb +0 -278
  136. data/examples/rr/space/space_example.rb +0 -29
  137. data/examples/rr/space/space_helper.rb +0 -7
  138. data/examples/rr/space/space_register_example.rb +0 -32
  139. data/examples/rr/space/space_reset_example.rb +0 -120
  140. data/examples/rr/space/space_verify_example.rb +0 -169
  141. data/examples/rr/times_called_matchers/any_times_matcher_example.rb +0 -63
  142. data/examples/rr/times_called_matchers/at_least_matcher_example.rb +0 -70
  143. data/examples/rr/times_called_matchers/at_most_matcher_example.rb +0 -85
  144. data/examples/rr/times_called_matchers/integer_matcher_example.rb +0 -91
  145. data/examples/rr/times_called_matchers/proc_matcher_example.rb +0 -77
  146. data/examples/rr/times_called_matchers/range_matcher_example.rb +0 -97
  147. data/examples/rr/times_called_matchers/times_called_matcher_example.rb +0 -53
  148. data/examples/rspec_example_suite.rb +0 -25
  149. data/lib/rr/extensions/instance_methods.rb +0 -228
  150. data/lib/rr/scenario.rb +0 -337
@@ -1,48 +0,0 @@
1
- require "examples/example_helper"
2
-
3
- module RR
4
- module Expectations
5
- describe ArgumentEqualityExpectation, "#exact_match? with is_a argument" do
6
- before do
7
- @expectation = ArgumentEqualityExpectation.new(boolean)
8
- end
9
-
10
- it "returns true when passed in an IsA module" do
11
- @expectation.should be_exact_match(WildcardMatchers::Boolean.new)
12
- end
13
-
14
- it "returns false otherwise" do
15
- @expectation.should_not be_exact_match("hello")
16
- @expectation.should_not be_exact_match(:hello)
17
- @expectation.should_not be_exact_match(1)
18
- @expectation.should_not be_exact_match(nil)
19
- @expectation.should_not be_exact_match(true)
20
- @expectation.should_not be_exact_match()
21
- end
22
- end
23
-
24
- describe ArgumentEqualityExpectation, "#wildcard_match? with is_a Boolean argument" do
25
- before do
26
- @expectation = ArgumentEqualityExpectation.new(boolean)
27
- end
28
-
29
- it "returns true when passed a Boolean" do
30
- @expectation.should be_wildcard_match(true)
31
- @expectation.should be_wildcard_match(false)
32
- end
33
-
34
- it "returns false when not passed a Boolean" do
35
- @expectation.should_not be_wildcard_match(:not_a_boolean)
36
- end
37
-
38
- it "returns true when an exact match" do
39
- @expectation.should be_wildcard_match(boolean)
40
- end
41
-
42
- it "returns false when not passed correct number of arguments" do
43
- @expectation.should_not be_wildcard_match()
44
- @expectation.should_not be_wildcard_match(true, false)
45
- end
46
- end
47
- end
48
- end
@@ -1,67 +0,0 @@
1
- require "examples/example_helper"
2
-
3
- module RR
4
- module Expectations
5
- describe ArgumentEqualityExpectation, "#exact_match? with duck_type argument" do
6
- before do
7
- @expectation = ArgumentEqualityExpectation.new(duck_type(:to_s))
8
- end
9
-
10
- it "returns true when passed in an DuckType matcher with the same argument list" do
11
- @expectation.should be_exact_match(WildcardMatchers::DuckType.new(:to_s))
12
- end
13
-
14
- it "returns false when passed in an DuckType matcher with a different argument list" do
15
- @expectation.should_not be_exact_match(WildcardMatchers::DuckType.new(:to_s, :to_i))
16
- end
17
-
18
- it "returns false otherwise" do
19
- @expectation.should_not be_exact_match("hello")
20
- @expectation.should_not be_exact_match(:hello)
21
- @expectation.should_not be_exact_match(1)
22
- @expectation.should_not be_exact_match(nil)
23
- @expectation.should_not be_exact_match(true)
24
- @expectation.should_not be_exact_match()
25
- end
26
- end
27
-
28
- describe ArgumentEqualityExpectation, "#wildcard_match? with DuckType argument" do
29
- before do
30
- @matching_object = Object.new
31
- def @matching_object.quack
32
- end
33
- def @matching_object.waddle
34
- end
35
-
36
- @partial_matching_object = Object.new
37
- def @partial_matching_object.quack
38
- end
39
-
40
- @not_match_object = Object.new
41
-
42
- @expectation = ArgumentEqualityExpectation.new(duck_type(:quack, :waddle))
43
- end
44
-
45
- it "returns true when object matches all required methods" do
46
- @expectation.should be_wildcard_match(@matching_object)
47
- end
48
-
49
- it "returns false when object matches some required methods" do
50
- @expectation.should_not be_wildcard_match(@partial_matching_object)
51
- end
52
-
53
- it "returns false when passed an object that matches no required methods" do
54
- @expectation.should_not be_wildcard_match(@not_match_object)
55
- end
56
-
57
- it "returns true when an exact match" do
58
- @expectation.should be_wildcard_match(duck_type(:quack, :waddle))
59
- end
60
-
61
- it "returns false when not passed correct number of arguments" do
62
- @expectation.should_not be_wildcard_match()
63
- @expectation.should_not be_wildcard_match(@matching_object, @matching_object)
64
- end
65
- end
66
- end
67
- end
@@ -1,50 +0,0 @@
1
- require "examples/example_helper"
2
-
3
- module RR
4
- module Expectations
5
- describe ArgumentEqualityExpectation, "#exact_match? with is_a argument" do
6
- before do
7
- @expectation = ArgumentEqualityExpectation.new(is_a(String))
8
- end
9
-
10
- it "returns true when passed in an IsA module" do
11
- @expectation.should be_exact_match(WildcardMatchers::IsA.new(String))
12
- end
13
-
14
- it "returns false when passed in an IsA object with a different module" do
15
- @expectation.should_not be_exact_match(WildcardMatchers::IsA.new(Integer))
16
- end
17
-
18
- it "returns false otherwise" do
19
- @expectation.should_not be_exact_match("hello")
20
- @expectation.should_not be_exact_match(:hello)
21
- @expectation.should_not be_exact_match(1)
22
- @expectation.should_not be_exact_match(nil)
23
- @expectation.should_not be_exact_match()
24
- end
25
- end
26
-
27
- describe ArgumentEqualityExpectation, "#wildcard_match? with is_a String argument" do
28
- before do
29
- @expectation = ArgumentEqualityExpectation.new(is_a(String))
30
- end
31
-
32
- it "returns true when passed a String" do
33
- @expectation.should be_wildcard_match("Hello")
34
- end
35
-
36
- it "returns false when not passed a String" do
37
- @expectation.should_not be_wildcard_match(:not_a_string)
38
- end
39
-
40
- it "returns true when an exact match" do
41
- @expectation.should be_wildcard_match(is_a(String))
42
- end
43
-
44
- it "returns false when not passed correct number of arguments" do
45
- @expectation.should_not be_wildcard_match()
46
- @expectation.should_not be_wildcard_match("one", "two")
47
- end
48
- end
49
- end
50
- end
@@ -1,46 +0,0 @@
1
- require "examples/example_helper"
2
-
3
- module RR
4
- module Expectations
5
- describe ArgumentEqualityExpectation, "#exact_match? with numeric argument" do
6
- before do
7
- @expectation = ArgumentEqualityExpectation.new(numeric)
8
- end
9
-
10
- it "returns true when passed in an IsA module" do
11
- @expectation.should be_exact_match(WildcardMatchers::Numeric.new)
12
- end
13
-
14
- it "returns false otherwise" do
15
- @expectation.should_not be_exact_match("hello")
16
- @expectation.should_not be_exact_match(:hello)
17
- @expectation.should_not be_exact_match(1)
18
- @expectation.should_not be_exact_match(nil)
19
- @expectation.should_not be_exact_match()
20
- end
21
- end
22
-
23
- describe ArgumentEqualityExpectation, "#wildcard_match? with Numeric argument" do
24
- before do
25
- @expectation = ArgumentEqualityExpectation.new(numeric)
26
- end
27
-
28
- it "returns true when passed a Numeric" do
29
- @expectation.should be_wildcard_match(99)
30
- end
31
-
32
- it "returns false when not passed a Numeric" do
33
- @expectation.should_not be_wildcard_match(:not_a_numeric)
34
- end
35
-
36
- it "returns true when an exact match" do
37
- @expectation.should be_wildcard_match(numeric)
38
- end
39
-
40
- it "returns false when not passed correct number of arguments" do
41
- @expectation.should_not be_wildcard_match()
42
- @expectation.should_not be_wildcard_match(1, 2)
43
- end
44
- end
45
- end
46
- end
@@ -1,59 +0,0 @@
1
- require "examples/example_helper"
2
-
3
- module RR
4
- module Expectations
5
- describe ArgumentEqualityExpectation, "#exact_match? with range argument" do
6
- before do
7
- @expectation = ArgumentEqualityExpectation.new(2..5)
8
- end
9
-
10
- it "returns true when passed in an Range matcher with the same argument list" do
11
- @expectation.should be_exact_match(2..5)
12
- end
13
-
14
- it "returns false when passed in an Range matcher with a different argument list" do
15
- @expectation.should_not be_exact_match(3..6)
16
- end
17
-
18
- it "returns false otherwise" do
19
- @expectation.should_not be_exact_match(2)
20
- @expectation.should_not be_exact_match(:hello)
21
- @expectation.should_not be_exact_match(3)
22
- @expectation.should_not be_exact_match(nil)
23
- @expectation.should_not be_exact_match(true)
24
- @expectation.should_not be_exact_match()
25
- end
26
- end
27
-
28
- describe ArgumentEqualityExpectation, "#wildcard_match? with Range argument" do
29
- before do
30
- @expectation = ArgumentEqualityExpectation.new(2..6)
31
- end
32
-
33
- it "returns true when string matches the range" do
34
- @expectation.should be_wildcard_match(3)
35
- end
36
-
37
- it "returns false when string does not match the range" do
38
- @expectation.should_not be_wildcard_match(7)
39
- end
40
-
41
- it "returns true when an exact match" do
42
- @expectation.should be_wildcard_match(2..6)
43
- end
44
-
45
- it "returns false when not an exact match" do
46
- @expectation.should_not be_wildcard_match(3..9)
47
- end
48
-
49
- it "returns false when not a number" do
50
- @expectation.should_not be_wildcard_match("Not a number")
51
- end
52
-
53
- it "returns false when not passed correct number of arguments" do
54
- @expectation.should_not be_wildcard_match()
55
- @expectation.should_not be_wildcard_match(2, 3)
56
- end
57
- end
58
- end
59
- end
@@ -1,67 +0,0 @@
1
- require "examples/example_helper"
2
-
3
- module RR
4
- module Expectations
5
- describe ArgumentEqualityExpectation, "#exact_match? with regexp argument" do
6
- before do
7
- @expectation = ArgumentEqualityExpectation.new(/abc/)
8
- end
9
-
10
- it "returns true when passed in an Regexp matcher with the same argument list" do
11
- @expectation.should be_exact_match(/abc/)
12
- end
13
-
14
- it "returns false when passed in an Regexp matcher with a different argument list" do
15
- @expectation.should_not be_exact_match(/def/)
16
- end
17
-
18
- it "returns false otherwise" do
19
- @expectation.should_not be_exact_match("abc")
20
- @expectation.should_not be_exact_match(:hello)
21
- @expectation.should_not be_exact_match(1)
22
- @expectation.should_not be_exact_match(nil)
23
- @expectation.should_not be_exact_match(true)
24
- @expectation.should_not be_exact_match()
25
- end
26
- end
27
-
28
- describe ArgumentEqualityExpectation, "#wildcard_match? with Regexp argument" do
29
- before do
30
- @matching_object = Object.new
31
- def @matching_object.quack
32
- end
33
- def @matching_object.waddle
34
- end
35
-
36
- @partial_matching_object = Object.new
37
- def @partial_matching_object.quack
38
- end
39
-
40
- @not_match_object = Object.new
41
-
42
- @expectation = ArgumentEqualityExpectation.new(/abc/)
43
- end
44
-
45
- it "returns true when string matches the regexp" do
46
- @expectation.should be_wildcard_match("Tabcola")
47
- end
48
-
49
- it "returns false when string does not match the regexp" do
50
- @expectation.should_not be_wildcard_match("no match here")
51
- end
52
-
53
- it "returns true when an exact match" do
54
- @expectation.should be_wildcard_match(/abc/)
55
- end
56
-
57
- it "returns false when not an exact match" do
58
- @expectation.should_not be_wildcard_match(/def/)
59
- end
60
-
61
- it "returns false when not passed correct number of arguments" do
62
- @expectation.should_not be_wildcard_match()
63
- @expectation.should_not be_wildcard_match('abc', 'abc')
64
- end
65
- end
66
- end
67
- end
@@ -1,50 +0,0 @@
1
- require "examples/example_helper"
2
-
3
- module RR
4
- module Expectations
5
- describe TimesCalledExpectation, ' with AnyTimesMatcher', :shared => true do
6
- it_should_behave_like "RR::Expectations::TimesCalledExpectation"
7
-
8
- before do
9
- @at_least = TimesCalledMatchers::AnyTimesMatcher.new
10
- @expectation = TimesCalledExpectation.new(@scenario, @at_least)
11
- end
12
- end
13
-
14
- describe TimesCalledExpectation, "#verify! with AnyTimesMatcher" do
15
- it_should_behave_like "RR::Expectations::TimesCalledExpectation with AnyTimesMatcher"
16
-
17
- it "always passes" do
18
- @expectation.verify!
19
- 10.times {@expectation.attempt!}
20
- @expectation.verify!
21
- end
22
- end
23
-
24
- describe TimesCalledExpectation, "#attempt? with AnyTimesMatcher" do
25
- it_should_behave_like "RR::Expectations::TimesCalledExpectation with AnyTimesMatcher"
26
-
27
- it "always returns true" do
28
- @expectation.should be_attempt
29
- 10.times {@expectation.attempt!}
30
- @expectation.should be_attempt
31
- end
32
- end
33
-
34
- describe TimesCalledExpectation, "#attempt! with AnyTimesMatcher" do
35
- it_should_behave_like "RR::Expectations::TimesCalledExpectation with AnyTimesMatcher"
36
-
37
- it "always passes" do
38
- 10.times {@expectation.attempt!}
39
- end
40
- end
41
-
42
- describe TimesCalledExpectation, "#terminal? with AnyTimesMatcher" do
43
- it_should_behave_like "RR::Expectations::TimesCalledExpectation with AnyTimesMatcher"
44
-
45
- it "returns false" do
46
- @expectation.should_not be_terminal
47
- end
48
- end
49
- end
50
- end
@@ -1,73 +0,0 @@
1
- require "examples/example_helper"
2
-
3
- module RR
4
- module Expectations
5
- describe TimesCalledExpectation, ' with AtLeastMatcher', :shared => true do
6
- it_should_behave_like "RR::Expectations::TimesCalledExpectation"
7
-
8
- before do
9
- @times = 3
10
- @at_least = TimesCalledMatchers::AtLeastMatcher.new(@times)
11
- @expectation = TimesCalledExpectation.new(@scenario, @at_least)
12
- end
13
- end
14
-
15
- describe TimesCalledExpectation, "#verify! with AtLeastMatcher" do
16
- it_should_behave_like "RR::Expectations::TimesCalledExpectation with AtLeastMatcher"
17
-
18
- it "passes when times called > times" do
19
- 4.times {@expectation.attempt!}
20
- @expectation.verify!
21
- end
22
-
23
- it "passes when times called == times" do
24
- 3.times {@expectation.attempt!}
25
- @expectation.verify!
26
- end
27
-
28
- it "raises error when times called < times" do
29
- @expectation.attempt!
30
- proc do
31
- @expectation.verify!
32
- end.should raise_error(
33
- RR::Errors::TimesCalledError,
34
- "foobar()\nCalled 1 time.\nExpected at least 3 times."
35
- )
36
- end
37
- end
38
-
39
- describe TimesCalledExpectation, "#attempt? with AtLeastMatcher" do
40
- it_should_behave_like "RR::Expectations::TimesCalledExpectation with AtLeastMatcher"
41
-
42
- it "always returns true" do
43
- @expectation.should be_attempt
44
- 10.times {@expectation.attempt!}
45
- @expectation.should be_attempt
46
- end
47
- end
48
-
49
- describe TimesCalledExpectation, "#attempt! with AtLeastMatcher" do
50
- it_should_behave_like "RR::Expectations::TimesCalledExpectation with AtLeastMatcher"
51
-
52
- it "passes when times called more than times" do
53
- 4.times {@expectation.attempt!}
54
- end
55
-
56
- it "passes when times called == times" do
57
- 3.times {@expectation.attempt!}
58
- end
59
-
60
- it "passes when times called < times" do
61
- @expectation.attempt!
62
- end
63
- end
64
-
65
- describe TimesCalledExpectation, "#terminal? with AtLeastMatcher" do
66
- it_should_behave_like "RR::Expectations::TimesCalledExpectation with AtLeastMatcher"
67
-
68
- it "returns false" do
69
- @expectation.should_not be_terminal
70
- end
71
- end
72
- end
73
- end