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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e73d8fe685e6cb4727955381137123cc1f949c1
4
- data.tar.gz: 2de42338dc1a9730ec2e0ba4918405bd807baf42
3
+ metadata.gz: afba7b74c4a3b74b76007242b439f17720f039c6
4
+ data.tar.gz: 517dac13240555cb8e0688f40b7077d56756e8e4
5
5
  SHA512:
6
- metadata.gz: 674d65b77d0e0bd9d7c3babd3bcd68a5737f8936cc5e0135996447de2e3bf44c0a86a44eff1682781b008473468c5701a585f3af29f326981cff94fe02c7428f
7
- data.tar.gz: 2ef280c1f4deea413790851d720e72680aca4be4e6d4a290b8ebd2879d074e6f3d984eb8dcadf1c7d1ede005a38fff3fd9437134475cc17a94fac2789ab2917d
6
+ metadata.gz: a660c1e4b7335d0db45770c906351070f317a00f4e6b76a1d1ce882efbbd0a8343f3854351a3d18540dcb33dd5c7a30470a1610828883262bcd7c36734bf6f4d
7
+ data.tar.gz: 4d406c3a9bf69bb7606f40df5231b31f79be461ea4e17fd01b8287ef37fd63e6bb4d6fc58592e2815793c20fc85030ec89ee6e40b44646f75e96cce0df2ad6b3
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,13 @@
1
+ === 5.8.3 / 2015-11-17
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Added extra note about mocks and threads to readme. (zamith)
6
+
7
+ * 1 bug fix:
8
+
9
+ * Fixed bug in Mock#verify. (pithub/zamith)
10
+
1
11
  === 5.8.2 / 2015-10-26
2
12
 
3
13
  * 1 bug fix:
@@ -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
@@ -7,7 +7,7 @@ require "minitest/parallel"
7
7
  # :include: README.rdoc
8
8
 
9
9
  module Minitest
10
- VERSION = "5.8.2" # :nodoc:
10
+ VERSION = "5.8.3" # :nodoc:
11
11
  ENCS = "".respond_to? :encoding # :nodoc:
12
12
 
13
13
  @@installed_at_exit ||= false
@@ -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") # => true
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, calls|
100
- calls.each do |expected|
101
- raise MockExpectationError, "expected #{__call name, expected}, got [#{__call name, @actual_calls[name]}]" if
102
- @actual_calls.key?(name) and
103
- not @actual_calls[name].include?(expected)
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.2
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-10-26 00:00:00.000000000 Z
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