jferris-mocha 0.9.5.0.1240351621 → 0.9.5.0.1241126838
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.
- data/lib/mocha/api.rb +1 -1
- data/test/acceptance/spy_test.rb +10 -1
- data/test/unit/assert_received_test.rb +10 -1
- data/test/unit/have_received_test.rb +18 -0
- metadata +2 -2
data/lib/mocha/api.rb
CHANGED
data/test/acceptance/spy_test.rb
CHANGED
@@ -85,7 +85,7 @@ module SpyTestMethods
|
|
85
85
|
assert_matcher_accepts have_received(:to_s).twice, instance
|
86
86
|
end
|
87
87
|
|
88
|
-
def
|
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
|
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.
|
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-
|
12
|
+
date: 2009-04-29 21:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|