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.
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
@@ -0,0 +1,55 @@
1
+ require "spec/spec_helper"
2
+
3
+ module RR
4
+ module TimesCalledMatchers
5
+ describe AtLeastMatcher do
6
+ attr_reader :matcher, :times
7
+ before do
8
+ @times = 3
9
+ @matcher = AtLeastMatcher.new(times)
10
+ end
11
+
12
+ describe "#possible_match?" do
13
+ it "always returns true" do
14
+ matcher.should be_possible_match(99999)
15
+ end
16
+ end
17
+
18
+ describe "#matches?" do
19
+ it "returns false when times_called less than times" do
20
+ matcher.should_not be_matches(2)
21
+ end
22
+
23
+ it "returns true when times_called == times" do
24
+ matcher.should be_matches(3)
25
+ end
26
+
27
+ it "returns true when times_called > times" do
28
+ matcher.should be_matches(4)
29
+ end
30
+ end
31
+
32
+ describe "#attempt?" do
33
+ it "always returns true" do
34
+ matcher.should be_attempt(1)
35
+ matcher.should be_attempt(100000)
36
+ end
37
+ end
38
+
39
+ describe AnyTimesMatcher, "#terminal?" do
40
+ it "returns false" do
41
+ matcher.should_not be_terminal
42
+ end
43
+ end
44
+
45
+ describe "#error_message" do
46
+ it "has an error message" do
47
+ matcher.error_message(2).should == (
48
+ "Called 2 times.\nExpected at least 3 times."
49
+ )
50
+ end
51
+ end
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,70 @@
1
+ require "spec/spec_helper"
2
+
3
+ module RR
4
+ module TimesCalledMatchers
5
+ describe AtMostMatcher do
6
+ attr_reader :matcher, :times
7
+ before do
8
+ @times = 3
9
+ @matcher = AtMostMatcher.new(times)
10
+ end
11
+
12
+ describe AtMostMatcher, "#possible_match?" do
13
+ it "returns true when times called < times" do
14
+ matcher.should be_possible_match(2)
15
+ end
16
+
17
+ it "returns true when times called == times" do
18
+ matcher.should be_possible_match(3)
19
+ end
20
+
21
+ it "returns false when times called > times" do
22
+ matcher.should_not be_possible_match(4)
23
+ end
24
+ end
25
+
26
+ describe AtMostMatcher, "#matches?" do
27
+ it "returns true when times_called less than times" do
28
+ matcher.should be_matches(2)
29
+ end
30
+
31
+ it "returns true when times_called == times" do
32
+ matcher.should be_matches(3)
33
+ end
34
+
35
+ it "returns false when times_called > times" do
36
+ matcher.should_not be_matches(4)
37
+ end
38
+ end
39
+
40
+ describe AtMostMatcher, "#attempt?" do
41
+ it "returns true when less than expected times" do
42
+ matcher.should be_attempt(2)
43
+ end
44
+
45
+ it "returns false when == expected times" do
46
+ matcher.should_not be_attempt(3)
47
+ end
48
+
49
+ it "returns false when > expected times" do
50
+ matcher.should_not be_attempt(4)
51
+ end
52
+ end
53
+
54
+ describe AnyTimesMatcher, "#terminal?" do
55
+ it "returns true" do
56
+ matcher.should be_terminal
57
+ end
58
+ end
59
+
60
+ describe AtMostMatcher, "#error_message" do
61
+ it "has an error message" do
62
+ matcher.error_message(5).should == (
63
+ "Called 5 times.\nExpected at most 3 times."
64
+ )
65
+ end
66
+ end
67
+ end
68
+
69
+ end
70
+ end
@@ -0,0 +1,70 @@
1
+ require "spec/spec_helper"
2
+
3
+ module RR
4
+ module TimesCalledMatchers
5
+ describe IntegerMatcher do
6
+ attr_reader :matcher, :times
7
+ before do
8
+ @times = 3
9
+ @matcher = IntegerMatcher.new(times)
10
+ end
11
+
12
+ describe "#possible_match?" do
13
+ it "returns true when times called < times" do
14
+ matcher.should be_possible_match(2)
15
+ end
16
+
17
+ it "returns true when times called == times" do
18
+ matcher.should be_possible_match(3)
19
+ end
20
+
21
+ it "returns false when times called > times" do
22
+ matcher.should_not be_possible_match(4)
23
+ end
24
+ end
25
+
26
+ describe "#matches?" do
27
+ it "returns false when times_called less than times" do
28
+ matcher.should_not be_matches(2)
29
+ end
30
+
31
+ it "returns true when times_called == times" do
32
+ matcher.should be_matches(3)
33
+ end
34
+
35
+ it "returns false when times_called > times" do
36
+ matcher.should_not be_matches(4)
37
+ end
38
+ end
39
+
40
+ describe "#attempt?" do
41
+ it "returns true when less than expected times" do
42
+ matcher.should be_attempt(2)
43
+ end
44
+
45
+ it "returns false when == expected times" do
46
+ matcher.should_not be_attempt(3)
47
+ end
48
+
49
+ it "returns false when > expected times" do
50
+ matcher.should_not be_attempt(4)
51
+ end
52
+ end
53
+
54
+ describe AnyTimesMatcher, "#terminal?" do
55
+ it "returns true" do
56
+ matcher.should be_terminal
57
+ end
58
+ end
59
+
60
+ describe "#error_message" do
61
+ it "has an error message" do
62
+ matcher.error_message(2).should == (
63
+ "Called 2 times.\nExpected 3 times."
64
+ )
65
+ end
66
+ end
67
+ end
68
+
69
+ end
70
+ end
@@ -0,0 +1,55 @@
1
+ require "spec/spec_helper"
2
+
3
+ module RR
4
+ module TimesCalledMatchers
5
+ describe ProcMatcher do
6
+ attr_reader :matcher, :times
7
+ before do
8
+ @times = proc {|other| other == 3}
9
+ @matcher = ProcMatcher.new(times)
10
+ end
11
+
12
+ describe "#possible_match?" do
13
+ it "always returns true" do
14
+ matcher.should be_possible_match(2)
15
+ matcher.should be_possible_match(3)
16
+ matcher.should be_possible_match(10)
17
+ end
18
+ end
19
+
20
+ describe "#matches?" do
21
+ it "returns false when proc returns false" do
22
+ times.call(2).should be_false
23
+ matcher.should_not be_matches(2)
24
+ end
25
+
26
+ it "returns true when proc returns true" do
27
+ times.call(3).should be_true
28
+ matcher.should be_matches(3)
29
+ end
30
+ end
31
+
32
+ describe "#attempt?" do
33
+ it "always returns true" do
34
+ matcher.should be_attempt(2)
35
+ matcher.should be_attempt(3)
36
+ matcher.should be_attempt(10)
37
+ end
38
+ end
39
+
40
+ describe "#terminal?" do
41
+ it "returns false" do
42
+ matcher.should_not be_terminal
43
+ end
44
+ end
45
+
46
+ describe "#error_message" do
47
+ it "has an error message" do
48
+ matcher.error_message(1).should =~
49
+ /Called 1 time.\nExpected #<Proc.*> times./
50
+ end
51
+ end
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,76 @@
1
+ require "spec/spec_helper"
2
+
3
+ module RR
4
+ module TimesCalledMatchers
5
+ describe RangeMatcher do
6
+ attr_reader :matcher, :times
7
+ before do
8
+ @times = 2..4
9
+ @matcher = RangeMatcher.new(times)
10
+ end
11
+
12
+ describe "#possible_match?" do
13
+ it "returns true when times called < start of range" do
14
+ matcher.should be_possible_match(1)
15
+ end
16
+
17
+ it "returns true when times called in range" do
18
+ matcher.should be_possible_match(2)
19
+ matcher.should be_possible_match(3)
20
+ matcher.should be_possible_match(4)
21
+ end
22
+
23
+ it "returns false when times called > end of range" do
24
+ matcher.should_not be_possible_match(5)
25
+ end
26
+ end
27
+
28
+ describe "#matches?" do
29
+ it "returns false when times_called less than start of range" do
30
+ matcher.should_not be_matches(1)
31
+ end
32
+
33
+ it "returns true when times_called in range" do
34
+ matcher.should be_matches(2)
35
+ matcher.should be_matches(3)
36
+ matcher.should be_matches(4)
37
+ end
38
+
39
+ it "returns false when times_called > end of range" do
40
+ matcher.should_not be_matches(5)
41
+ end
42
+ end
43
+
44
+ describe "#attempt?" do
45
+ it "returns true when less than start of range" do
46
+ matcher.should be_attempt(1)
47
+ end
48
+
49
+ it "returns true when in range" do
50
+ matcher.should be_attempt(2)
51
+ matcher.should be_attempt(3)
52
+ matcher.should be_attempt(4)
53
+ end
54
+
55
+ it "returns false when > end of range" do
56
+ matcher.should_not be_attempt(5)
57
+ end
58
+ end
59
+
60
+ describe "#terminal?" do
61
+ it "returns true" do
62
+ matcher.should be_terminal
63
+ end
64
+ end
65
+
66
+ describe "#error_message" do
67
+ it "has an error message" do
68
+ matcher.error_message(1).should == (
69
+ "Called 1 time.\nExpected 2..4 times."
70
+ )
71
+ end
72
+ end
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,118 @@
1
+ require "spec/spec_helper"
2
+
3
+ module RR
4
+ module TimesCalledMatchers
5
+ describe TimesCalledMatcher do
6
+ describe ".create" do
7
+ describe "when passed a AnyTimesMatcher" do
8
+ it "returns the passed in argument" do
9
+ matcher = AnyTimesMatcher.new
10
+ TimesCalledMatcher.create(matcher).should === matcher
11
+ end
12
+ end
13
+
14
+ describe "when passed a AtLeastMatcher" do
15
+ it "returns the passed in argument" do
16
+ matcher = AtLeastMatcher.new(5)
17
+ TimesCalledMatcher.create(matcher).should === matcher
18
+ end
19
+ end
20
+
21
+ describe "when passed a AtMostMatcher" do
22
+ it "returns the passed in argument" do
23
+ matcher = AtMostMatcher.new(5)
24
+ TimesCalledMatcher.create(matcher).should === matcher
25
+ end
26
+ end
27
+
28
+ describe "when passed a IntegerMatcher" do
29
+ it "returns the passed in argument" do
30
+ matcher = IntegerMatcher.new(5)
31
+ TimesCalledMatcher.create(matcher).should === matcher
32
+ end
33
+ end
34
+
35
+ describe "when passed a Integer" do
36
+ it "returns IntegerMatcher" do
37
+ TimesCalledMatcher.create(5).should == IntegerMatcher.new(5)
38
+ end
39
+ end
40
+
41
+ describe "when passed a ProcMatcher" do
42
+ it "returns the passed in argument" do
43
+ matcher = ProcMatcher.new(proc {|other| other == 5})
44
+ TimesCalledMatcher.create(matcher).should === matcher
45
+ end
46
+ end
47
+
48
+ describe "when passed a Lambda" do
49
+ it "returns ProcMatcher" do
50
+ value = proc {|other| other == 5}
51
+ TimesCalledMatcher.create(value).should == ProcMatcher.new(value)
52
+ end
53
+ end
54
+
55
+ describe "when passed a IntegerMatcher" do
56
+ it "returns the passed in argument" do
57
+ matcher = RangeMatcher.new(2..4)
58
+ TimesCalledMatcher.create(matcher).should === matcher
59
+ end
60
+ end
61
+
62
+ describe "when passed a Integer" do
63
+ it "returns RangeMatcher" do
64
+ TimesCalledMatcher.create(2..4).should == RangeMatcher.new(2..4)
65
+ end
66
+ end
67
+
68
+ describe "when passed a TimesCalledMatcher" do
69
+ it "returns the passed in argument" do
70
+ matcher = TimesCalledMatcher.new(5)
71
+ TimesCalledMatcher.create(matcher).should === matcher
72
+ end
73
+ end
74
+
75
+ describe "when passed an unsupported type" do
76
+ it "raises an ArgumentError" do
77
+ matcher = Object.new
78
+ proc do
79
+ TimesCalledMatcher.create(matcher)
80
+ end.should raise_error(ArgumentError, "There is no TimesCalledMatcher for #{matcher.inspect}.")
81
+ end
82
+ end
83
+ end
84
+
85
+ describe "#error_message" do
86
+ before do
87
+ @times = 3
88
+ @matcher = TimesCalledMatcher.new(@times)
89
+ end
90
+
91
+ it "has an error message" do
92
+ @matcher.error_message(5).should == (
93
+ "Called 5 times.\nExpected 3 times."
94
+ )
95
+ end
96
+ end
97
+
98
+ describe "#==" do
99
+ before do
100
+ @times = 3
101
+ @matcher = TimesCalledMatcher.new(@times)
102
+ end
103
+
104
+ it "returns true when other is the same class and times are ==" do
105
+ @matcher.should == TimesCalledMatcher.new(@times)
106
+ end
107
+
108
+ it "returns false when other is a different class and times are ==" do
109
+ @matcher.should_not == IntegerMatcher.new(@times)
110
+ end
111
+
112
+ it "returns false when is the same class and times are not ==" do
113
+ @matcher.should_not == TimesCalledMatcher.new(1)
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end