rr 1.0.4 → 1.0.5.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +15 -0
  2. data/CHANGES.md +376 -0
  3. data/Gemfile +7 -10
  4. data/README.md +822 -0
  5. data/Rakefile +24 -78
  6. data/VERSION +1 -0
  7. data/lib/rr.rb +3 -0
  8. data/lib/rr/adapters/minitest.rb +6 -0
  9. data/lib/rr/adapters/rr_methods.rb +6 -10
  10. data/lib/rr/adapters/rspec.rb +3 -0
  11. data/lib/rr/adapters/rspec2.rb +30 -0
  12. data/lib/rr/adapters/test_unit.rb +2 -0
  13. data/lib/rr/double.rb +3 -2
  14. data/lib/rr/double_definitions/child_double_definition_create.rb +3 -2
  15. data/lib/rr/double_definitions/double_definition.rb +15 -13
  16. data/lib/rr/double_definitions/double_definition_create.rb +9 -5
  17. data/lib/rr/double_definitions/double_injections/any_instance_of.rb +3 -2
  18. data/lib/rr/double_definitions/strategies/strategy.rb +5 -4
  19. data/lib/rr/double_definitions/strategies/strategy_methods.rb +6 -8
  20. data/lib/rr/double_definitions/strategies/verification/mock.rb +3 -3
  21. data/lib/rr/double_matches.rb +2 -1
  22. data/lib/rr/expectations/argument_equality_expectation.rb +2 -2
  23. data/lib/rr/expectations/times_called_expectation.rb +2 -2
  24. data/lib/rr/injections/double_injection.rb +12 -11
  25. data/lib/rr/injections/injection.rb +2 -2
  26. data/lib/rr/injections/method_missing_injection.rb +21 -7
  27. data/lib/rr/injections/singleton_method_added_injection.rb +3 -1
  28. data/lib/rr/method_dispatches/base_method_dispatch.rb +1 -1
  29. data/lib/rr/method_dispatches/method_dispatch.rb +2 -1
  30. data/lib/rr/method_dispatches/method_missing_dispatch.rb +2 -1
  31. data/lib/rr/proc_from_block.rb +8 -4
  32. data/lib/rr/space.rb +3 -2
  33. data/lib/rr/times_called_matchers/times_called_matcher.rb +2 -2
  34. data/lib/rr/version.rb +5 -0
  35. data/lib/rr/wildcard_matchers/boolean.rb +2 -2
  36. data/spec/runner.rb +41 -0
  37. metadata +45 -133
  38. data/.gitignore +0 -10
  39. data/.runrc +0 -3
  40. data/.rvmrc +0 -2
  41. data/CHANGES +0 -266
  42. data/Gemfile.lock +0 -31
  43. data/README.rdoc +0 -392
  44. data/benchmarks/rr_benchmark.rb +0 -32
  45. data/benchmarks/rspec_benchmark.rb +0 -14
  46. data/doc/0.6.0.release.markdown +0 -81
  47. data/doc/todo.txt +0 -0
  48. data/introducting_rr.txt +0 -206
  49. data/rr.gemspec +0 -37
  50. data/spec/api/any_instance_of/all_instances_of_spec.rb +0 -12
  51. data/spec/api/any_instance_of/any_instance_of_spec.rb +0 -47
  52. data/spec/api/any_instance_of/instance_of_spec.rb +0 -12
  53. data/spec/api/dont_allow/dont_allow_after_stub_spec.rb +0 -14
  54. data/spec/api/mock/mock_spec.rb +0 -193
  55. data/spec/api/proxy/proxy_spec.rb +0 -86
  56. data/spec/api/spy/spy_spec.rb +0 -49
  57. data/spec/api/strong/strong_spec.rb +0 -87
  58. data/spec/api/stub/stub_spec.rb +0 -152
  59. data/spec/core_spec_suite.rb +0 -19
  60. data/spec/environment_fixture_setup.rb +0 -8
  61. data/spec/minitest_spec_suite.rb +0 -21
  62. data/spec/proc_from_block_spec.rb +0 -14
  63. data/spec/rr/adapters/rr_methods_argument_matcher_spec.rb +0 -67
  64. data/spec/rr/adapters/rr_methods_creator_spec.rb +0 -137
  65. data/spec/rr/adapters/rr_methods_space_spec.rb +0 -98
  66. data/spec/rr/adapters/rr_methods_spec_helper.rb +0 -11
  67. data/spec/rr/adapters/rr_methods_times_matcher_spec.rb +0 -13
  68. data/spec/rr/double_definitions/child_double_definition_creator_spec.rb +0 -112
  69. data/spec/rr/double_definitions/double_definition_create_blank_slate_spec.rb +0 -91
  70. data/spec/rr/double_definitions/double_definition_create_spec.rb +0 -443
  71. data/spec/rr/double_injection/double_injection_spec.rb +0 -546
  72. data/spec/rr/double_injection/double_injection_verify_spec.rb +0 -29
  73. data/spec/rr/errors/rr_error_spec.rb +0 -67
  74. data/spec/rr/expectations/any_argument_expectation_spec.rb +0 -47
  75. data/spec/rr/expectations/anything_argument_equality_expectation_spec.rb +0 -14
  76. data/spec/rr/expectations/argument_equality_expectation_spec.rb +0 -135
  77. data/spec/rr/expectations/boolean_argument_equality_expectation_spec.rb +0 -34
  78. data/spec/rr/expectations/hash_including_argument_equality_expectation_spec.rb +0 -82
  79. data/spec/rr/expectations/hash_including_spec.rb +0 -17
  80. data/spec/rr/expectations/satisfy_argument_equality_expectation_spec.rb +0 -59
  81. data/spec/rr/expectations/satisfy_spec.rb +0 -14
  82. data/spec/rr/expectations/times_called_expectation/times_called_expectation_any_times_spec.rb +0 -22
  83. data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb +0 -37
  84. data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_most_spec.rb +0 -43
  85. data/spec/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +0 -15
  86. data/spec/rr/expectations/times_called_expectation/times_called_expectation_integer_spec.rb +0 -58
  87. data/spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb +0 -35
  88. data/spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb +0 -39
  89. data/spec/rr/minitest/minitest_integration_test.rb +0 -59
  90. data/spec/rr/minitest/test_helper.rb +0 -7
  91. data/spec/rr/rspec/invocation_matcher_spec.rb +0 -279
  92. data/spec/rr/rspec/rspec_adapter_spec.rb +0 -63
  93. data/spec/rr/rspec/rspec_backtrace_tweaking_spec.rb +0 -31
  94. data/spec/rr/rspec/rspec_backtrace_tweaking_spec_fixture.rb +0 -11
  95. data/spec/rr/rspec/rspec_usage_spec.rb +0 -86
  96. data/spec/rr/space/hash_with_object_id_key_spec.rb +0 -88
  97. data/spec/rr/space/space_spec.rb +0 -596
  98. data/spec/rr/test_unit/test_helper.rb +0 -7
  99. data/spec/rr/test_unit/test_unit_backtrace_test.rb +0 -36
  100. data/spec/rr/test_unit/test_unit_integration_test.rb +0 -59
  101. data/spec/rr/times_called_matchers/any_times_matcher_spec.rb +0 -47
  102. data/spec/rr/times_called_matchers/at_least_matcher_spec.rb +0 -55
  103. data/spec/rr/times_called_matchers/at_most_matcher_spec.rb +0 -70
  104. data/spec/rr/times_called_matchers/integer_matcher_spec.rb +0 -70
  105. data/spec/rr/times_called_matchers/proc_matcher_spec.rb +0 -55
  106. data/spec/rr/times_called_matchers/range_matcher_spec.rb +0 -76
  107. data/spec/rr/times_called_matchers/times_called_matcher_spec.rb +0 -118
  108. data/spec/rr/wildcard_matchers/anything_spec.rb +0 -24
  109. data/spec/rr/wildcard_matchers/boolean_spec.rb +0 -36
  110. data/spec/rr/wildcard_matchers/duck_type_spec.rb +0 -52
  111. data/spec/rr/wildcard_matchers/is_a_spec.rb +0 -32
  112. data/spec/rr/wildcard_matchers/numeric_spec.rb +0 -32
  113. data/spec/rr/wildcard_matchers/range_spec.rb +0 -35
  114. data/spec/rr/wildcard_matchers/regexp_spec.rb +0 -43
  115. data/spec/rr_spec.rb +0 -28
  116. data/spec/rspec_spec_suite.rb +0 -17
  117. data/spec/spec.opts +0 -10
  118. data/spec/spec_helper.rb +0 -41
  119. data/spec/spec_suite.rb +0 -54
  120. data/spec/spy_verification_spec.rb +0 -129
  121. data/spec/test_unit_spec_suite.rb +0 -21
@@ -1,14 +0,0 @@
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
@@ -1,22 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../../spec_helper")
2
-
3
- module RR
4
- module Expectations
5
- describe TimesCalledExpectation do
6
- context "when using an AnyTimesMatcher" do
7
- it_should_behave_like "RR::Expectations::TimesCalledExpectation"
8
-
9
- describe "#verify!" do
10
- it "always passes" do
11
- stub(subject).foobar.any_number_of_times
12
- RR.verify
13
-
14
- stub(subject).foobar.any_number_of_times
15
- 10.times {subject.foobar}
16
- RR.verify
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,37 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../../spec_helper")
2
-
3
- module RR
4
- module Expectations
5
- describe TimesCalledExpectation do
6
- context "when using an AtLeastMatcher" do
7
- it_should_behave_like "RR::Expectations::TimesCalledExpectation"
8
-
9
- before do
10
- mock(subject).foobar.at_least(3)
11
- end
12
-
13
- describe "#verify!" do
14
- it "passes when times called > times" do
15
- 4.times {subject.foobar}
16
- RR.verify
17
- end
18
-
19
- it "passes when times called == times" do
20
- 3.times {subject.foobar}
21
- RR.verify
22
- end
23
-
24
- it "raises error when times called < times" do
25
- subject.foobar
26
- lambda do
27
- RR.verify
28
- end.should raise_error(
29
- RR::Errors::TimesCalledError,
30
- "foobar()\nCalled 1 time.\nExpected at least 3 times."
31
- )
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,43 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../../spec_helper")
2
-
3
- module RR
4
- module Expectations
5
- describe TimesCalledExpectation do
6
- context "when using an AtMostMatcher" do
7
- it_should_behave_like "RR::Expectations::TimesCalledExpectation"
8
-
9
- before do
10
- stub(subject).foobar.at_most(3)
11
- end
12
-
13
- describe "#verify!" do
14
- it "passes when times called == times" do
15
- 3.times {subject.foobar}
16
- RR.verify
17
- end
18
-
19
- it "passes when times called < times" do
20
- 2.times {subject.foobar}
21
- RR.verify
22
- end
23
-
24
- it "raises error when times called > times" do
25
- lambda do
26
- 4.times {subject.foobar}
27
- end.should raise_error(
28
- RR::Errors::TimesCalledError,
29
- "foobar()\nCalled 4 times.\nExpected at most 3 times."
30
- )
31
-
32
- lambda do
33
- RR.verify
34
- end.should raise_error(
35
- RR::Errors::TimesCalledError,
36
- "foobar()\nCalled 4 times.\nExpected at most 3 times."
37
- )
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,15 +0,0 @@
1
- module RR
2
- module Expectations
3
- describe TimesCalledExpectation, :shared => true do
4
- attr_reader :subject
5
- it_should_behave_like "Swapped Space"
6
- before do
7
- @subject = Object.new
8
- end
9
-
10
- def raises_expectation_error(&block)
11
- lambda {block.call}.should raise_error(RR::Errors::TimesCalledError)
12
- end
13
- end
14
- end
15
- end
@@ -1,58 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../../spec_helper")
2
-
3
- module RR
4
- module Expectations
5
- describe TimesCalledExpectation do
6
- context "when using an IntegerMatcher" do
7
- it_should_behave_like "RR::Expectations::TimesCalledExpectation"
8
-
9
- before do
10
- stub(subject).foobar.times(2)
11
- end
12
-
13
- describe "verify" do
14
- it "passes after attempt! called 2 times" do
15
- subject.foobar
16
- subject.foobar
17
- RR.verify
18
- end
19
-
20
- it "fails after attempt! called 1 time" do
21
- subject.foobar
22
- lambda {RR.verify}.should raise_error(
23
- RR::Errors::TimesCalledError,
24
- "foobar()\nCalled 1 time.\nExpected 2 times."
25
- )
26
- end
27
-
28
- it "can't be called when attempt! is called 3 times" do
29
- subject.foobar
30
- subject.foobar
31
- lambda do
32
- subject.foobar
33
- end.should raise_error(RR::Errors::TimesCalledError, "foobar()\nCalled 3 times.\nExpected 2 times.")
34
- lambda do
35
- RR.verify
36
- end.should raise_error(RR::Errors::TimesCalledError, "foobar()\nCalled 3 times.\nExpected 2 times.")
37
- end
38
-
39
- it "has a backtrace to where the TimesCalledExpectation was instantiated on failure" do
40
- error = nil
41
- begin
42
- RR.verify
43
- rescue RR::Errors::TimesCalledError => e
44
- error = e
45
- end
46
- e.backtrace.join("\n").should include(__FILE__)
47
- end
48
-
49
- it "has an error message that includes the number of times called and expected number of times" do
50
- lambda do
51
- RR.verify
52
- end.should raise_error(RR::Errors::TimesCalledError, "foobar()\nCalled 0 times.\nExpected 2 times.")
53
- end
54
- end
55
- end
56
- end
57
- end
58
- end
@@ -1,35 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../../spec_helper")
2
-
3
- module RR
4
- module Expectations
5
- describe TimesCalledExpectation do
6
- context "when using a ProcMatcher" do
7
- it_should_behave_like "RR::Expectations::TimesCalledExpectation"
8
-
9
- before do
10
- stub(subject).foobar.times(lambda {|value| value == 2})
11
- end
12
-
13
- describe "#verify" do
14
- it "passes after attempt! called 2 times" do
15
- subject.foobar
16
- subject.foobar
17
- RR.verify
18
- end
19
-
20
- it "fails after attempt! called 1 time" do
21
- subject.foobar
22
- lambda {RR.verify}.should raise_error(RR::Errors::TimesCalledError)
23
- end
24
-
25
- it "fails after attempt! called 3 times" do
26
- subject.foobar
27
- subject.foobar
28
- subject.foobar
29
- lambda {RR.verify}.should raise_error(RR::Errors::TimesCalledError)
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,39 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../../spec_helper")
2
-
3
- module RR
4
- module Expectations
5
- describe TimesCalledExpectation do
6
- context "when using a RangeMatcher" do
7
- it_should_behave_like "RR::Expectations::TimesCalledExpectation"
8
-
9
- before do
10
- stub(subject).foobar.times(1..2)
11
- end
12
-
13
- describe "#verify" do
14
- it "passes after attempt! called 1 time" do
15
- subject.foobar
16
- RR.verify
17
- end
18
-
19
- it "passes after attempt! called 2 times" do
20
- subject.foobar
21
- subject.foobar
22
- RR.verify
23
- end
24
-
25
- it "can't be called when attempt! is called 3 times" do
26
- subject.foobar
27
- subject.foobar
28
- lambda do
29
- subject.foobar
30
- end.should raise_error(RR::Errors::TimesCalledError, "foobar()\nCalled 3 times.\nExpected 1..2 times.")
31
- lambda do
32
- RR.verify
33
- end.should raise_error(RR::Errors::TimesCalledError, "foobar()\nCalled 3 times.\nExpected 1..2 times.")
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,59 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
-
3
- class MiniTestIntegrationTest < MiniTest::Unit::TestCase
4
- include RR::Adapters::MiniTest # Testing against double inclusion issues
5
-
6
- def setup
7
- super
8
- @subject = Object.new
9
- end
10
-
11
- def teardown
12
- super
13
- end
14
-
15
- def test_using_a_mock
16
- mock(@subject).foobar(1, 2) {:baz}
17
- assert_equal :baz, @subject.foobar(1, 2)
18
- end
19
-
20
- def test_using_a_stub
21
- stub(@subject).foobar {:baz}
22
- assert_equal :baz, @subject.foobar("any", "thing")
23
- end
24
-
25
- def test_using_a_mock_proxy
26
- def @subject.foobar
27
- :baz
28
- end
29
-
30
- mock.proxy(@subject).foobar
31
- assert_equal :baz, @subject.foobar
32
- end
33
-
34
- def test_using_a_stub_proxy
35
- def @subject.foobar
36
- :baz
37
- end
38
-
39
- stub.proxy(@subject).foobar
40
- assert_equal :baz, @subject.foobar
41
- end
42
-
43
- def test_times_called_verification
44
- mock(@subject).foobar(1, 2) {:baz}
45
- assert_raises RR::Errors::TimesCalledError do
46
- teardown
47
- end
48
- end
49
-
50
- def test_using_assert_received
51
- stub(@subject).foobar(1, 2)
52
- @subject.foobar(1, 2)
53
- assert_received(@subject) {|subject| subject.foobar(1, 2)}
54
-
55
- assert_raises RR::Errors::SpyVerificationErrors::InvocationCountError do
56
- assert_received(@subject) {|subject| subject.foobar(1, 2, 3)}
57
- end
58
- end
59
- end
@@ -1,7 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../environment_fixture_setup")
2
-
3
- require "minitest/autorun"
4
-
5
- class MiniTest::Unit::TestCase
6
- include RR::Adapters::MiniTest
7
- end
@@ -1,279 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
2
-
3
- module RR
4
- module Adapters
5
- module Rspec
6
- describe InvocationMatcher do
7
- describe "matching against a method with no doubles" do
8
- before do
9
- @matcher = InvocationMatcher.new(:foobar)
10
- @result = @matcher.matches?(Object.new)
11
- end
12
-
13
- it "does not match" do
14
- @result.should_not be
15
- end
16
- end
17
-
18
- describe "defining an expectation using a method invocation" do
19
- before do
20
- @subject = Object.new
21
- stub(@subject).foobar
22
- @subject.foobar(:args)
23
- @result = InvocationMatcher.new.foobar(:args).matches?(@subject)
24
- end
25
-
26
- it "uses the invoked method as the expected method" do
27
- @result.should be
28
- end
29
- end
30
-
31
- describe "matching against a stubbed method that was never called" do
32
- before do
33
- @subject = Object.new
34
- stub(@subject).foobar
35
- @matcher = InvocationMatcher.new(:foobar)
36
- @result = @matcher.matches?(@subject)
37
- end
38
-
39
- it "does not match" do
40
- @result.should_not be
41
- end
42
- end
43
-
44
- describe "matching against a stubbed method that was called once" do
45
- before do
46
- @subject = Object.new
47
- stub(@subject).foobar
48
- @subject.foobar
49
- @result = InvocationMatcher.new(:foobar).matches?(@subject)
50
- end
51
-
52
- it "does match" do
53
- @result.should be
54
- end
55
- end
56
-
57
- describe "matching against a stubbed method that was called with unexpected arguments" do
58
- before do
59
- @args = %w(one two)
60
- @subject = Object.new
61
- stub(@subject).foobar
62
- @subject.foobar(:other)
63
- @result = InvocationMatcher.new(:foobar).with(*@args).matches?(@subject)
64
- end
65
-
66
- it "does not match" do
67
- @result.should_not be
68
- end
69
- end
70
-
71
- describe "matching against a stubbed method that was called with expected arguments" do
72
- before do
73
- @args = %w(one two)
74
- @subject = Object.new
75
- stub(@subject).foobar
76
- @subject.foobar(*@args)
77
- @result = InvocationMatcher.new(:foobar).with(*@args).matches?(@subject)
78
- end
79
-
80
- it "does match" do
81
- @result.should be
82
- end
83
- end
84
-
85
- describe "defining a fulfilled argument expectation using a method invocation" do
86
- before do
87
- @args = %w(one two)
88
- @subject = Object.new
89
- stub(@subject).foobar
90
- @subject.foobar(*@args)
91
- @result = InvocationMatcher.new.foobar(*@args).matches?(@subject)
92
- end
93
-
94
- it "does match" do
95
- @result.should be
96
- end
97
- end
98
-
99
- describe "defining an unfulfilled argument expectation using a method invocation" do
100
- before do
101
- @args = %w(one two)
102
- @subject = Object.new
103
- stub(@subject).foobar
104
- @subject.foobar(:other)
105
- @result = InvocationMatcher.new.foobar(*@args).matches?(@subject)
106
- end
107
-
108
- it "does not match" do
109
- @result.should_not be
110
- end
111
- end
112
-
113
- describe "matching against a stubbed method that was called more than once" do
114
- before do
115
- @subject = Object.new
116
- stub(@subject).foobar
117
- 2.times { @subject.foobar }
118
- @result = InvocationMatcher.new(:foobar).twice.matches?(@subject)
119
- end
120
-
121
- it "does match" do
122
- @result.should be
123
- end
124
- end
125
-
126
- describe "matching a stubbed method with any arguments" do
127
- before do
128
- @subject = Object.new
129
- stub(@subject).foobar
130
- @subject.foobar(:args)
131
- @result = InvocationMatcher.new(:foobar).with_any_args.matches?(@subject)
132
- end
133
-
134
- it "does match" do
135
- @result.should be
136
- end
137
- end
138
-
139
- describe "matching a stubbed method with no arguments when arguments are not provided" do
140
- before do
141
- @subject = Object.new
142
- stub(@subject).foobar
143
- @subject.foobar
144
- @result = InvocationMatcher.new(:foobar).with_no_args.matches?(@subject)
145
- end
146
-
147
- it "does match" do
148
- @result.should be
149
- end
150
- end
151
-
152
- describe "matching a stubbed method with no arguments when arguments are provided" do
153
- before do
154
- @subject = Object.new
155
- stub(@subject).foobar
156
- @subject.foobar(:args)
157
- @result = InvocationMatcher.new(:foobar).with_no_args.matches?(@subject)
158
- end
159
-
160
- it "does not match" do
161
- @result.should_not be
162
- end
163
- end
164
-
165
- describe "matching a method that was called twice when expected once" do
166
- before do
167
- @subject = Object.new
168
- stub(@subject).foobar
169
- 2.times { @subject.foobar }
170
- @matcher = InvocationMatcher.new(:foobar).times(1)
171
- @result = @matcher.matches?(@subject)
172
- end
173
-
174
- it "does not match" do
175
- @result.should_not be
176
- end
177
- end
178
-
179
- describe "matching a method that was called twice when expected twice" do
180
- before do
181
- @subject = Object.new
182
- stub(@subject).foobar
183
- 2.times { @subject.foobar }
184
- @result = InvocationMatcher.new(:foobar).times(2).matches?(@subject)
185
- end
186
-
187
- it "does match" do
188
- @result.should be
189
- end
190
- end
191
-
192
- describe "matching a method that was called twice when any number of times" do
193
- before do
194
- @subject = Object.new
195
- stub(@subject).foobar
196
- 2.times { @subject.foobar }
197
- @result = InvocationMatcher.new(:foobar).any_number_of_times.matches?(@subject)
198
- end
199
-
200
- it "does match" do
201
- @result.should be
202
- end
203
- end
204
-
205
- describe "matching a method that was called three times when expected at most twice" do
206
- before do
207
- @subject = Object.new
208
- stub(@subject).foobar
209
- 3.times { @subject.foobar }
210
- @result = InvocationMatcher.new(:foobar).at_most(2).matches?(@subject)
211
- end
212
-
213
- it "does not match" do
214
- @result.should_not be
215
- end
216
- end
217
-
218
- describe "matching a method that was called once when expected at most twice" do
219
- before do
220
- @subject = Object.new
221
- stub(@subject).foobar
222
- @subject.foobar
223
- @result = InvocationMatcher.new(:foobar).at_most(2).matches?(@subject)
224
- end
225
-
226
- it "does match" do
227
- @result.should be
228
- end
229
- end
230
-
231
- describe "matching a method that was called once when expected at least twice" do
232
- before do
233
- @subject = Object.new
234
- stub(@subject).foobar
235
- @subject.foobar
236
- @result = InvocationMatcher.new(:foobar).at_least(2).matches?(@subject)
237
- end
238
-
239
- it "does not match" do
240
- @result.should_not be
241
- end
242
- end
243
-
244
- describe "matching a method that was called three times when expected at least twice" do
245
- before do
246
- @subject = Object.new
247
- stub(@subject).foobar
248
- 3.times { @subject.foobar }
249
- @result = InvocationMatcher.new(:foobar).at_least(2).matches?(@subject)
250
- end
251
-
252
- it "does match" do
253
- @result.should be
254
- end
255
- end
256
-
257
- describe "that does not match" do
258
- before do
259
- @error = Object.new
260
- @message = 'Verification error message'
261
- stub(RR::Space.instance.recorded_calls).match_error { @error }
262
- stub(@error).message { @message }
263
-
264
- @matcher = InvocationMatcher.new(:foobar)
265
- @result = @matcher.matches?(Object.new)
266
- end
267
-
268
- it "returns false when matching" do
269
- @result.should_not be
270
- end
271
-
272
- it "returns a failure messsage" do
273
- @matcher.failure_message.should == @message
274
- end
275
- end
276
- end
277
- end
278
- end
279
- end