jferris-mocha 0.9.5.0.1240351621 → 0.9.5.0.1241126838

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mocha/api.rb CHANGED
@@ -185,7 +185,7 @@ module Mocha # :nodoc:
185
185
  @expectation.send(method, *args, &block)
186
186
  end
187
187
  @expectation.invocation_count = invocation_count
188
- @expectation.satisfied?
188
+ @expectation.verified?
189
189
  end
190
190
 
191
191
  def failure_message
@@ -85,7 +85,7 @@ module SpyTestMethods
85
85
  assert_matcher_accepts have_received(:to_s).twice, instance
86
86
  end
87
87
 
88
- def test_should_reject_incorrect_number_of_calls
88
+ def test_should_reject_not_enough_calls
89
89
  instance = new_instance
90
90
  instance.stubs(:to_s)
91
91
  instance.to_s
@@ -94,6 +94,15 @@ module SpyTestMethods
94
94
  assert_fails(message) { assert_matcher_accepts have_received(:to_s).twice, instance }
95
95
  end
96
96
 
97
+ def test_should_reject_too_many_calls
98
+ instance = new_instance
99
+ instance.stubs(:to_s)
100
+ 2.times { instance.to_s }
101
+ message = /expected exactly once/
102
+ assert_fails(message) { assert_received(instance, :to_s) {|expect| expect.once } }
103
+ assert_fails(message) { assert_matcher_accepts have_received(:to_s).once, instance }
104
+ end
105
+
97
106
  def assert_fails(message=/not yet invoked/)
98
107
  begin
99
108
  yield
@@ -107,7 +107,7 @@ class AssertReceivedTest < Test::Unit::TestCase
107
107
  end
108
108
  end
109
109
 
110
- def test_fails_if_invocation_count_incorrect
110
+ def test_fails_if_invocation_count_too_low
111
111
  method = :a_method
112
112
  mock = FakeMock.new('a mock')
113
113
  Mockery.instance.invocation(mock, method, [])
@@ -116,6 +116,15 @@ class AssertReceivedTest < Test::Unit::TestCase
116
116
  end
117
117
  end
118
118
 
119
+ def test_fails_if_invocation_count_too_high
120
+ method = :a_method
121
+ mock = FakeMock.new('a mock')
122
+ 2.times { Mockery.instance.invocation(mock, method, []) }
123
+ assert_fails do
124
+ assert_received(mock, method) {|expect| expect.once }
125
+ end
126
+ end
127
+
119
128
  def assert_passes(&block)
120
129
  assert ! fails?(&block)
121
130
  end
@@ -101,6 +101,24 @@ module HaveReceivedTestMethods
101
101
  end
102
102
  end
103
103
 
104
+ def test_fails_if_invocation_count_too_low
105
+ method = :a_method
106
+ mock = new_mock('a mock')
107
+ Mockery.instance.invocation(mock, method, [])
108
+ assert_fails do
109
+ assert_matcher_accepts have_received(method).twice, mock
110
+ end
111
+ end
112
+
113
+ def test_fails_if_invocation_count_too_high
114
+ method = :a_method
115
+ mock = new_mock('a mock')
116
+ 2.times { Mockery.instance.invocation(mock, method, []) }
117
+ assert_fails do
118
+ assert_matcher_accepts have_received(method).once, mock
119
+ end
120
+ end
121
+
104
122
  def assert_passes(&block)
105
123
  assert ! fails?(&block)
106
124
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jferris-mocha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5.0.1240351621
4
+ version: 0.9.5.0.1241126838
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Mead
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-20 21:00:00 -07:00
12
+ date: 2009-04-29 21:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency