minitest 5.10.3 → 5.18.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,10 +9,11 @@
9
9
  #
10
10
  # it "should still work in threads" do
11
11
  # my_threaded_thingy do
12
- # (1+1).must_equal 2 # bad
13
- # assert_equal 2, 1+1 # good
14
- # _(1 + 1).must_equal 2 # good
15
- # value(1 + 1).must_equal 2 # good, also #expect
12
+ # (1+1).must_equal 2 # bad
13
+ # assert_equal 2, 1+1 # good
14
+ # _(1 + 1).must_equal 2 # good
15
+ # value(1 + 1).must_equal 2 # good, also #expect
16
+ # _ { 1 + "1" }.must_raise TypeError # good
16
17
  # end
17
18
  # end
18
19
 
@@ -21,7 +22,7 @@ module Minitest::Expectations
21
22
  ##
22
23
  # See Minitest::Assertions#assert_empty.
23
24
  #
24
- # collection.must_be_empty
25
+ # _(collection).must_be_empty
25
26
  #
26
27
  # :method: must_be_empty
27
28
 
@@ -30,7 +31,7 @@ module Minitest::Expectations
30
31
  ##
31
32
  # See Minitest::Assertions#assert_equal
32
33
  #
33
- # a.must_equal b
34
+ # _(a).must_equal b
34
35
  #
35
36
  # :method: must_equal
36
37
 
@@ -39,18 +40,18 @@ module Minitest::Expectations
39
40
  ##
40
41
  # See Minitest::Assertions#assert_in_delta
41
42
  #
42
- # n.must_be_close_to m [, delta]
43
+ # _(n).must_be_close_to m [, delta]
43
44
  #
44
45
  # :method: must_be_close_to
45
46
 
46
47
  infect_an_assertion :assert_in_delta, :must_be_close_to
47
48
 
48
- alias :must_be_within_delta :must_be_close_to # :nodoc:
49
+ infect_an_assertion :assert_in_delta, :must_be_within_delta # :nodoc:
49
50
 
50
51
  ##
51
52
  # See Minitest::Assertions#assert_in_epsilon
52
53
  #
53
- # n.must_be_within_epsilon m [, epsilon]
54
+ # _(n).must_be_within_epsilon m [, epsilon]
54
55
  #
55
56
  # :method: must_be_within_epsilon
56
57
 
@@ -59,7 +60,7 @@ module Minitest::Expectations
59
60
  ##
60
61
  # See Minitest::Assertions#assert_includes
61
62
  #
62
- # collection.must_include obj
63
+ # _(collection).must_include obj
63
64
  #
64
65
  # :method: must_include
65
66
 
@@ -68,7 +69,7 @@ module Minitest::Expectations
68
69
  ##
69
70
  # See Minitest::Assertions#assert_instance_of
70
71
  #
71
- # obj.must_be_instance_of klass
72
+ # _(obj).must_be_instance_of klass
72
73
  #
73
74
  # :method: must_be_instance_of
74
75
 
@@ -77,7 +78,7 @@ module Minitest::Expectations
77
78
  ##
78
79
  # See Minitest::Assertions#assert_kind_of
79
80
  #
80
- # obj.must_be_kind_of mod
81
+ # _(obj).must_be_kind_of mod
81
82
  #
82
83
  # :method: must_be_kind_of
83
84
 
@@ -86,7 +87,7 @@ module Minitest::Expectations
86
87
  ##
87
88
  # See Minitest::Assertions#assert_match
88
89
  #
89
- # a.must_match b
90
+ # _(a).must_match b
90
91
  #
91
92
  # :method: must_match
92
93
 
@@ -95,7 +96,7 @@ module Minitest::Expectations
95
96
  ##
96
97
  # See Minitest::Assertions#assert_nil
97
98
  #
98
- # obj.must_be_nil
99
+ # _(obj).must_be_nil
99
100
  #
100
101
  # :method: must_be_nil
101
102
 
@@ -104,11 +105,11 @@ module Minitest::Expectations
104
105
  ##
105
106
  # See Minitest::Assertions#assert_operator
106
107
  #
107
- # n.must_be :<=, 42
108
+ # _(n).must_be :<=, 42
108
109
  #
109
110
  # This can also do predicates:
110
111
  #
111
- # str.must_be :empty?
112
+ # _(str).must_be :empty?
112
113
  #
113
114
  # :method: must_be
114
115
 
@@ -117,16 +118,25 @@ module Minitest::Expectations
117
118
  ##
118
119
  # See Minitest::Assertions#assert_output
119
120
  #
120
- # proc { ... }.must_output out_or_nil [, err]
121
+ # _ { ... }.must_output out_or_nil [, err]
121
122
  #
122
123
  # :method: must_output
123
124
 
124
125
  infect_an_assertion :assert_output, :must_output, :block
125
126
 
127
+ ##
128
+ # See Minitest::Assertions#assert_pattern_match
129
+ #
130
+ # _ { ... }.must_pattern_match [...]
131
+ #
132
+ # :method: must_pattern_match
133
+
134
+ infect_an_assertion :assert_pattern, :must_pattern_match, :block
135
+
126
136
  ##
127
137
  # See Minitest::Assertions#assert_raises
128
138
  #
129
- # proc { ... }.must_raise exception
139
+ # _ { ... }.must_raise exception
130
140
  #
131
141
  # :method: must_raise
132
142
 
@@ -135,7 +145,7 @@ module Minitest::Expectations
135
145
  ##
136
146
  # See Minitest::Assertions#assert_respond_to
137
147
  #
138
- # obj.must_respond_to msg
148
+ # _(obj).must_respond_to msg
139
149
  #
140
150
  # :method: must_respond_to
141
151
 
@@ -144,7 +154,7 @@ module Minitest::Expectations
144
154
  ##
145
155
  # See Minitest::Assertions#assert_same
146
156
  #
147
- # a.must_be_same_as b
157
+ # _(a).must_be_same_as b
148
158
  #
149
159
  # :method: must_be_same_as
150
160
 
@@ -153,7 +163,7 @@ module Minitest::Expectations
153
163
  ##
154
164
  # See Minitest::Assertions#assert_silent
155
165
  #
156
- # proc { ... }.must_be_silent
166
+ # _ { ... }.must_be_silent
157
167
  #
158
168
  # :method: must_be_silent
159
169
 
@@ -162,16 +172,34 @@ module Minitest::Expectations
162
172
  ##
163
173
  # See Minitest::Assertions#assert_throws
164
174
  #
165
- # proc { ... }.must_throw sym
175
+ # _ { ... }.must_throw sym
166
176
  #
167
177
  # :method: must_throw
168
178
 
169
179
  infect_an_assertion :assert_throws, :must_throw, :block
170
180
 
181
+ ##
182
+ # See Minitest::Assertions#assert_path_exists
183
+ #
184
+ # _(some_path).path_must_exist
185
+ #
186
+ # :method: path_must_exist
187
+
188
+ infect_an_assertion :assert_path_exists, :path_must_exist, :unary
189
+
190
+ ##
191
+ # See Minitest::Assertions#refute_path_exists
192
+ #
193
+ # _(some_path).path_wont_exist
194
+ #
195
+ # :method: path_wont_exist
196
+
197
+ infect_an_assertion :refute_path_exists, :path_wont_exist, :unary
198
+
171
199
  ##
172
200
  # See Minitest::Assertions#refute_empty
173
201
  #
174
- # collection.wont_be_empty
202
+ # _(collection).wont_be_empty
175
203
  #
176
204
  # :method: wont_be_empty
177
205
 
@@ -180,7 +208,7 @@ module Minitest::Expectations
180
208
  ##
181
209
  # See Minitest::Assertions#refute_equal
182
210
  #
183
- # a.wont_equal b
211
+ # _(a).wont_equal b
184
212
  #
185
213
  # :method: wont_equal
186
214
 
@@ -189,18 +217,18 @@ module Minitest::Expectations
189
217
  ##
190
218
  # See Minitest::Assertions#refute_in_delta
191
219
  #
192
- # n.wont_be_close_to m [, delta]
220
+ # _(n).wont_be_close_to m [, delta]
193
221
  #
194
222
  # :method: wont_be_close_to
195
223
 
196
224
  infect_an_assertion :refute_in_delta, :wont_be_close_to
197
225
 
198
- alias :wont_be_within_delta :wont_be_close_to # :nodoc:
226
+ infect_an_assertion :refute_in_delta, :wont_be_within_delta # :nodoc:
199
227
 
200
228
  ##
201
229
  # See Minitest::Assertions#refute_in_epsilon
202
230
  #
203
- # n.wont_be_within_epsilon m [, epsilon]
231
+ # _(n).wont_be_within_epsilon m [, epsilon]
204
232
  #
205
233
  # :method: wont_be_within_epsilon
206
234
 
@@ -209,7 +237,7 @@ module Minitest::Expectations
209
237
  ##
210
238
  # See Minitest::Assertions#refute_includes
211
239
  #
212
- # collection.wont_include obj
240
+ # _(collection).wont_include obj
213
241
  #
214
242
  # :method: wont_include
215
243
 
@@ -218,7 +246,7 @@ module Minitest::Expectations
218
246
  ##
219
247
  # See Minitest::Assertions#refute_instance_of
220
248
  #
221
- # obj.wont_be_instance_of klass
249
+ # _(obj).wont_be_instance_of klass
222
250
  #
223
251
  # :method: wont_be_instance_of
224
252
 
@@ -227,7 +255,7 @@ module Minitest::Expectations
227
255
  ##
228
256
  # See Minitest::Assertions#refute_kind_of
229
257
  #
230
- # obj.wont_be_kind_of mod
258
+ # _(obj).wont_be_kind_of mod
231
259
  #
232
260
  # :method: wont_be_kind_of
233
261
 
@@ -236,7 +264,7 @@ module Minitest::Expectations
236
264
  ##
237
265
  # See Minitest::Assertions#refute_match
238
266
  #
239
- # a.wont_match b
267
+ # _(a).wont_match b
240
268
  #
241
269
  # :method: wont_match
242
270
 
@@ -245,7 +273,7 @@ module Minitest::Expectations
245
273
  ##
246
274
  # See Minitest::Assertions#refute_nil
247
275
  #
248
- # obj.wont_be_nil
276
+ # _(obj).wont_be_nil
249
277
  #
250
278
  # :method: wont_be_nil
251
279
 
@@ -254,7 +282,7 @@ module Minitest::Expectations
254
282
  ##
255
283
  # See Minitest::Assertions#refute_operator
256
284
  #
257
- # n.wont_be :<=, 42
285
+ # _(n).wont_be :<=, 42
258
286
  #
259
287
  # This can also do predicates:
260
288
  #
@@ -264,10 +292,19 @@ module Minitest::Expectations
264
292
 
265
293
  infect_an_assertion :refute_operator, :wont_be, :reverse
266
294
 
295
+ ##
296
+ # See Minitest::Assertions#refute_pattern_match
297
+ #
298
+ # _ { ... }.wont_pattern_match [...]
299
+ #
300
+ # :method: wont_pattern_match
301
+
302
+ infect_an_assertion :refute_pattern, :wont_pattern_match, :block
303
+
267
304
  ##
268
305
  # See Minitest::Assertions#refute_respond_to
269
306
  #
270
- # obj.wont_respond_to msg
307
+ # _(obj).wont_respond_to msg
271
308
  #
272
309
  # :method: wont_respond_to
273
310
 
@@ -276,7 +313,7 @@ module Minitest::Expectations
276
313
  ##
277
314
  # See Minitest::Assertions#refute_same
278
315
  #
279
- # a.wont_be_same_as b
316
+ # _(a).wont_be_same_as b
280
317
  #
281
318
  # :method: wont_be_same_as
282
319
 
data/lib/minitest/mock.rb CHANGED
@@ -28,11 +28,19 @@ module Minitest # :nodoc:
28
28
  end
29
29
 
30
30
  overridden_methods.map(&:to_sym).each do |method_id|
31
- define_method method_id do |*args, &b|
31
+ define_method method_id do |*args, **kwargs, &b|
32
32
  if @expected_calls.key? method_id then
33
- method_missing(method_id, *args, &b)
33
+ if kwargs.empty? then # FIX: drop this after 2.7 dead
34
+ method_missing(method_id, *args, &b)
35
+ else
36
+ method_missing(method_id, *args, **kwargs, &b)
37
+ end
34
38
  else
35
- super(*args, &b)
39
+ if kwargs.empty? then # FIX: drop this after 2.7 dead
40
+ super(*args, &b)
41
+ else
42
+ super(*args, **kwargs, &b)
43
+ end
36
44
  end
37
45
  end
38
46
  end
@@ -43,9 +51,11 @@ module Minitest # :nodoc:
43
51
  @actual_calls = Hash.new { |calls, name| calls[name] = [] }
44
52
  end
45
53
 
54
+ @@KW_WARNED = false # :nodoc:
55
+
46
56
  ##
47
- # Expect that method +name+ is called, optionally with +args+ or a
48
- # +blk+, and returns +retval+.
57
+ # Expect that method +name+ is called, optionally with +args+ (and
58
+ # +kwargs+ or a +blk+), and returns +retval+.
49
59
  #
50
60
  # @mock.expect(:meaning_of_life, 42)
51
61
  # @mock.meaning_of_life # => 42
@@ -78,15 +88,31 @@ module Minitest # :nodoc:
78
88
  # @mock.ordinal_increment # => raises MockExpectationError "No more expects available for :ordinal_increment"
79
89
  #
80
90
 
81
- def expect name, retval, args = [], &blk
91
+ def expect name, retval, args = [], **kwargs, &blk
82
92
  name = name.to_sym
83
93
 
84
94
  if block_given?
85
95
  raise ArgumentError, "args ignored when block given" unless args.empty?
96
+ raise ArgumentError, "kwargs ignored when block given" unless kwargs.empty?
86
97
  @expected_calls[name] << { :retval => retval, :block => blk }
87
98
  else
88
99
  raise ArgumentError, "args must be an array" unless Array === args
89
- @expected_calls[name] << { :retval => retval, :args => args }
100
+
101
+ if ENV["MT_KWARGS_HAC\K"] && (Hash === args.last ||
102
+ Hash == args.last) then
103
+ if kwargs.empty? then
104
+ kwargs = args.pop
105
+ else
106
+ unless @@KW_WARNED then
107
+ from = caller.first
108
+ warn "Using MT_KWARGS_HAC\K yet passing kwargs. From #{from}"
109
+ @@KW_WARNED = true
110
+ end
111
+ end
112
+ end
113
+
114
+ @expected_calls[name] <<
115
+ { :retval => retval, :args => args, :kwargs => kwargs }
90
116
  end
91
117
  self
92
118
  end
@@ -94,7 +120,13 @@ module Minitest # :nodoc:
94
120
  def __call name, data # :nodoc:
95
121
  case data
96
122
  when Hash then
97
- "#{name}(#{data[:args].inspect[1..-2]}) => #{data[:retval].inspect}"
123
+ args = data[:args].inspect[1..-2]
124
+ kwargs = data[:kwargs]
125
+ if kwargs && !kwargs.empty? then
126
+ args << ", " unless args.empty?
127
+ args << kwargs.inspect[1..-2]
128
+ end
129
+ "#{name}(#{args}) => #{data[:retval].inspect}"
98
130
  else
99
131
  data.map { |d| __call name, d }.join ", "
100
132
  end
@@ -115,10 +147,14 @@ module Minitest # :nodoc:
115
147
  true
116
148
  end
117
149
 
118
- def method_missing sym, *args, &block # :nodoc:
150
+ def method_missing sym, *args, **kwargs, &block # :nodoc:
119
151
  unless @expected_calls.key?(sym) then
120
152
  if @delegator && @delegator.respond_to?(sym)
121
- return @delegator.public_send(sym, *args, &block)
153
+ if kwargs.empty? then # FIX: drop this after 2.7 dead
154
+ return @delegator.public_send(sym, *args, &block)
155
+ else
156
+ return @delegator.public_send(sym, *args, **kwargs, &block)
157
+ end
122
158
  else
123
159
  raise NoMethodError, "unmocked method %p, expected one of %p" %
124
160
  [sym, @expected_calls.keys.sort_by(&:to_s)]
@@ -129,26 +165,34 @@ module Minitest # :nodoc:
129
165
  expected_call = @expected_calls[sym][index]
130
166
 
131
167
  unless expected_call then
132
- raise MockExpectationError, "No more expects available for %p: %p" %
133
- [sym, args]
168
+ raise MockExpectationError, "No more expects available for %p: %p %p" %
169
+ [sym, args, kwargs]
134
170
  end
135
171
 
136
- expected_args, retval, val_block =
137
- expected_call.values_at(:args, :retval, :block)
172
+ expected_args, expected_kwargs, retval, val_block =
173
+ expected_call.values_at(:args, :kwargs, :retval, :block)
174
+
175
+ expected_kwargs = kwargs.map { |ak, av| [ak, Object] }.to_h if
176
+ Hash == expected_kwargs
138
177
 
139
178
  if val_block then
140
179
  # keep "verify" happy
141
180
  @actual_calls[sym] << expected_call
142
181
 
143
- raise MockExpectationError, "mocked method %p failed block w/ %p" %
144
- [sym, args] unless val_block.call(*args, &block)
182
+ raise MockExpectationError, "mocked method %p failed block w/ %p %p" %
183
+ [sym, args, kwargs] unless val_block.call(*args, **kwargs, &block)
145
184
 
146
185
  return retval
147
186
  end
148
187
 
149
188
  if expected_args.size != args.size then
150
- raise ArgumentError, "mocked method %p expects %d arguments, got %d" %
151
- [sym, expected_args.size, args.size]
189
+ raise ArgumentError, "mocked method %p expects %d arguments, got %p" %
190
+ [sym, expected_args.size, args]
191
+ end
192
+
193
+ if expected_kwargs.size != kwargs.size then
194
+ raise ArgumentError, "mocked method %p expects %d keyword arguments, got %p" %
195
+ [sym, expected_kwargs.size, kwargs]
152
196
  end
153
197
 
154
198
  zipped_args = expected_args.zip(args)
@@ -157,13 +201,33 @@ module Minitest # :nodoc:
157
201
  }
158
202
 
159
203
  unless fully_matched then
160
- raise MockExpectationError, "mocked method %p called with unexpected arguments %p" %
161
- [sym, args]
204
+ fmt = "mocked method %p called with unexpected arguments %p"
205
+ raise MockExpectationError, fmt % [sym, args]
206
+ end
207
+
208
+ unless expected_kwargs.keys.sort == kwargs.keys.sort then
209
+ fmt = "mocked method %p called with unexpected keywords %p vs %p"
210
+ raise MockExpectationError, fmt % [sym, expected_kwargs.keys, kwargs.keys]
211
+ end
212
+
213
+ zipped_kwargs = expected_kwargs.map { |ek, ev|
214
+ av = kwargs[ek]
215
+ [ek, [ev, av]]
216
+ }.to_h
217
+
218
+ fully_matched = zipped_kwargs.all? { |ek, (ev, av)|
219
+ ev === av or ev == av
220
+ }
221
+
222
+ unless fully_matched then
223
+ fmt = "mocked method %p called with unexpected keyword arguments %p vs %p"
224
+ raise MockExpectationError, fmt % [sym, expected_kwargs, kwargs]
162
225
  end
163
226
 
164
227
  @actual_calls[sym] << {
165
228
  :retval => retval,
166
- :args => zipped_args.map! { |mod, a| mod === a ? mod : a },
229
+ :args => zipped_args.map { |e, a| e === a ? e : a },
230
+ :kwargs => zipped_kwargs.map { |k, (e, a)| [k, e === a ? e : a] }.to_h,
167
231
  }
168
232
 
169
233
  retval
@@ -207,34 +271,54 @@ class Object
207
271
  # assert obj_under_test.stale?
208
272
  # end
209
273
  # end
210
- #
274
+ #--
275
+ # NOTE: keyword args in callables are NOT checked for correctness
276
+ # against the existing method. Too many edge cases to be worth it.
211
277
 
212
- def stub name, val_or_callable, *block_args
278
+ def stub name, val_or_callable, *block_args, **block_kwargs, &block
213
279
  new_name = "__minitest_stub__#{name}"
214
280
 
215
281
  metaclass = class << self; self; end
216
282
 
217
283
  if respond_to? name and not methods.map(&:to_s).include? name.to_s then
218
- metaclass.send :define_method, name do |*args|
219
- super(*args)
284
+ metaclass.send :define_method, name do |*args, **kwargs|
285
+ super(*args, **kwargs)
220
286
  end
221
287
  end
222
288
 
223
289
  metaclass.send :alias_method, new_name, name
224
290
 
225
- metaclass.send :define_method, name do |*args, &blk|
226
- ret = if val_or_callable.respond_to? :call then
227
- val_or_callable.call(*args)
291
+ if ENV["MT_KWARGS_HAC\K"] then
292
+ metaclass.send :define_method, name do |*args, &blk|
293
+ if val_or_callable.respond_to? :call then
294
+ val_or_callable.call(*args, &blk)
295
+ else
296
+ blk.call(*block_args, **block_kwargs) if blk
297
+ val_or_callable
298
+ end
299
+ end
300
+ else
301
+ metaclass.send :define_method, name do |*args, **kwargs, &blk|
302
+ if val_or_callable.respond_to? :call then
303
+ if kwargs.empty? then # FIX: drop this after 2.7 dead
304
+ val_or_callable.call(*args, &blk)
305
+ else
306
+ val_or_callable.call(*args, **kwargs, &blk)
307
+ end
308
+ else
309
+ if blk then
310
+ if block_kwargs.empty? then # FIX: drop this after 2.7 dead
311
+ blk.call(*block_args)
228
312
  else
229
- val_or_callable
313
+ blk.call(*block_args, **block_kwargs)
230
314
  end
231
-
232
- blk.call(*block_args) if blk
233
-
234
- ret
315
+ end
316
+ val_or_callable
317
+ end
318
+ end
235
319
  end
236
320
 
237
- yield self
321
+ block[self]
238
322
  ensure
239
323
  metaclass.send :undef_method, name
240
324
  metaclass.send :alias_method, name, new_name
@@ -53,7 +53,7 @@ module Minitest
53
53
  end
54
54
  end
55
55
 
56
- module Test
56
+ module Test # :nodoc:
57
57
  def _synchronize; Minitest::Test.io_lock.synchronize { yield }; end # :nodoc:
58
58
 
59
59
  module ClassMethods # :nodoc:
@@ -48,7 +48,7 @@ module Minitest
48
48
  def initialize io # :nodoc:
49
49
  @io = io
50
50
  # stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm
51
- # also reference http://en.wikipedia.org/wiki/ANSI_escape_code
51
+ # also reference https://en.wikipedia.org/wiki/ANSI_escape_code
52
52
  @colors ||= (31..36).to_a
53
53
  @size = @colors.size
54
54
  @index = 0
data/lib/minitest/spec.rb CHANGED
@@ -4,16 +4,26 @@ class Module # :nodoc:
4
4
  def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
5
5
  block = dont_flip == :block
6
6
  dont_flip = false if block
7
+ target_obj = block ? '_{obj.method}' : '_(obj)'
8
+
9
+ # https://eregon.me/blog/2021/02/13/correct-delegation-in-ruby-2-27-3.html
10
+ # Drop this when we can drop ruby 2.6 (aka after rails 6.1 EOL, ~2024-06)
11
+ kw_extra = "ruby2_keywords %p" % [new_name] if respond_to?(:ruby2_keywords, true)
7
12
 
8
13
  # warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
9
14
  self.class_eval <<-EOM, __FILE__, __LINE__ + 1
10
15
  def #{new_name} *args
16
+ where = Minitest.filter_backtrace(caller).first
17
+ where = where.split(/:in /, 2).first # clean up noise
18
+ Kernel.warn "DEPRECATED: global use of #{new_name} from #\{where}. Use #{target_obj}.#{new_name} instead. This will fail in Minitest 6."
11
19
  Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args)
12
20
  end
21
+ #{kw_extra}
13
22
  EOM
14
23
 
15
24
  Minitest::Expectation.class_eval <<-EOM, __FILE__, __LINE__ + 1
16
25
  def #{new_name} *args
26
+ raise "Calling ##{new_name} outside of test." unless ctx
17
27
  case
18
28
  when #{!!dont_flip} then
19
29
  ctx.#{meth}(target, *args)
@@ -23,6 +33,7 @@ class Module # :nodoc:
23
33
  ctx.#{meth}(args.first, target, *args[1..-1])
24
34
  end
25
35
  end
36
+ #{kw_extra}
26
37
  EOM
27
38
  end
28
39
  end
@@ -61,7 +72,7 @@ module Kernel
61
72
  #
62
73
  # For some suggestions on how to improve your specs, try:
63
74
  #
64
- # http://betterspecs.org
75
+ # https://betterspecs.org
65
76
  #
66
77
  # but do note that several items there are debatable or specific to
67
78
  # rspec.
@@ -285,21 +296,28 @@ class Minitest::Spec < Minitest::Test
285
296
 
286
297
  module InstanceMethods
287
298
  ##
288
- # Returns a value monad that has all of Expectations methods
289
- # available to it.
299
+ # Takes a value or a block and returns a value monad that has
300
+ # all of Expectations methods available to it.
290
301
  #
291
- # Also aliased to #value and #expect for your aesthetic pleasure:
302
+ # _(1 + 1).must_equal 2
292
303
  #
293
- # _(1 + 1).must_equal 2
294
- # value(1 + 1).must_equal 2
295
- # expect(1 + 1).must_equal 2
304
+ # And for blocks:
305
+ #
306
+ # _ { 1 + "1" }.must_raise TypeError
296
307
  #
297
308
  # This method of expectation-based testing is preferable to
298
309
  # straight-expectation methods (on Object) because it stores its
299
310
  # test context, bypassing our hacky use of thread-local variables.
300
311
  #
301
- # At some point, the methods on Object will be deprecated and then
302
- # removed.
312
+ # NOTE: At some point, the methods on Object will be deprecated
313
+ # and then removed.
314
+ #
315
+ # It is also aliased to #value and #expect for your aesthetic
316
+ # pleasure:
317
+ #
318
+ # _(1 + 1).must_equal 2
319
+ # value(1 + 1).must_equal 2
320
+ # expect(1 + 1).must_equal 2
303
321
 
304
322
  def _ value = nil, &block
305
323
  Minitest::Expectation.new block || value, self