minitest 5.8.2 → 5.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +10 -0
- data/README.rdoc +14 -0
- data/lib/minitest.rb +1 -1
- data/lib/minitest/mock.rb +6 -12
- data/test/minitest/test_minitest_mock.rb +14 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afba7b74c4a3b74b76007242b439f17720f039c6
|
4
|
+
data.tar.gz: 517dac13240555cb8e0688f40b7077d56756e8e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a660c1e4b7335d0db45770c906351070f317a00f4e6b76a1d1ce882efbbd0a8343f3854351a3d18540dcb33dd5c7a30470a1610828883262bcd7c36734bf6f4d
|
7
|
+
data.tar.gz: 4d406c3a9bf69bb7606f40df5231b31f79be461ea4e17fd01b8287ef37fd63e6bb4d6fc58592e2815793c20fc85030ec89ee6e40b44646f75e96cce0df2ad6b3
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -219,6 +219,20 @@ verification to ensure they got all the calls they were expecting."
|
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
222
|
+
**Multi-threading and Mocks**
|
223
|
+
|
224
|
+
Minitest mocks do not support multi-threading if it works, fine, if it doesn't
|
225
|
+
you can use regular ruby patterns and facilities like local variables. Here's
|
226
|
+
an example of asserting that code inside a thread is run:
|
227
|
+
|
228
|
+
def test_called_inside_thread
|
229
|
+
called = false
|
230
|
+
pr = Proc.new { called = true }
|
231
|
+
thread = Thread.new(&pr)
|
232
|
+
thread.join
|
233
|
+
assert called, "proc not called"
|
234
|
+
end
|
235
|
+
|
222
236
|
=== Stubs
|
223
237
|
|
224
238
|
Mocks and stubs are defined using terminology by Fowler & Meszaros at
|
data/lib/minitest.rb
CHANGED
data/lib/minitest/mock.rb
CHANGED
@@ -65,8 +65,7 @@ module Minitest # :nodoc:
|
|
65
65
|
# @mock.verify # => true
|
66
66
|
#
|
67
67
|
# @mock.expect(:uses_one_string, true, ["foo"])
|
68
|
-
# @mock.uses_one_string("bar") # =>
|
69
|
-
# @mock.verify # => raises MockExpectationError
|
68
|
+
# @mock.uses_one_string("bar") # => raises MockExpectationError
|
70
69
|
|
71
70
|
def expect(name, retval, args = [], &blk)
|
72
71
|
name = name.to_sym
|
@@ -96,16 +95,11 @@ module Minitest # :nodoc:
|
|
96
95
|
# expected.
|
97
96
|
|
98
97
|
def verify
|
99
|
-
@expected_calls.each do |name,
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
raise MockExpectationError, "expected #{__call name, expected}" unless
|
106
|
-
@actual_calls.key?(name) and
|
107
|
-
@actual_calls[name].include?(expected)
|
108
|
-
end
|
98
|
+
@expected_calls.each do |name, expected|
|
99
|
+
actual = @actual_calls.fetch(name, nil)
|
100
|
+
raise MockExpectationError, "expected #{__call name, expected[0]}" unless actual
|
101
|
+
raise MockExpectationError, "expected #{__call name, expected[actual.size]}, got [#{__call name, actual}]" if
|
102
|
+
actual.size < expected.size
|
109
103
|
end
|
110
104
|
true
|
111
105
|
end
|
@@ -240,6 +240,20 @@ class TestMinitestMock < Minitest::Test
|
|
240
240
|
assert_equal exp, e.message
|
241
241
|
end
|
242
242
|
|
243
|
+
def test_same_method_expects_with_same_args_blow_up_when_not_all_called
|
244
|
+
mock = Minitest::Mock.new
|
245
|
+
mock.expect :foo, nil, [:bar]
|
246
|
+
mock.expect :foo, nil, [:bar]
|
247
|
+
|
248
|
+
mock.foo :bar
|
249
|
+
|
250
|
+
e = assert_raises(MockExpectationError) { mock.verify }
|
251
|
+
|
252
|
+
exp = "expected foo(:bar) => nil, got [foo(:bar) => nil]"
|
253
|
+
|
254
|
+
assert_equal exp, e.message
|
255
|
+
end
|
256
|
+
|
243
257
|
def test_verify_passes_when_mock_block_returns_true
|
244
258
|
mock = Minitest::Mock.new
|
245
259
|
mock.expect :foo, nil do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.8.
|
4
|
+
version: 5.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
qx3h45R1CAsObX0SQDIT+rRbQrtKz1GHIZTOFYvEJjUY1XmRTZupD3CJ8Q7sDqSy
|
30
30
|
NLq5jm1fq6Y9Uolu3RJbmycf
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2015-
|
32
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rdoc
|
metadata.gz.sig
CHANGED
Binary file
|