Skip to content

Commit

Permalink
- Improved documentation for _/value/expect, especially for blocks. (…
Browse files Browse the repository at this point in the history
…svoop)

[git-p4: depot-paths = "//src/minitest/dev/": change = 12333]
  • Loading branch information
zenspider committed Oct 1, 2019
1 parent 7af05b7 commit 15ed8e4
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions lib/minitest/spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,21 +289,28 @@ def to_s # :nodoc:

module InstanceMethods
##
# Returns a value monad that has all of Expectations methods
# available to it.
# Takes a value or a block and returns a value monad that has
# all of Expectations methods available to it.
#
# Also aliased to #value and #expect for your aesthetic pleasure:
# _(1 + 1).must_equal 2
#
# _(1 + 1).must_equal 2
# value(1 + 1).must_equal 2
# expect(1 + 1).must_equal 2
# And for blocks:
#
# _ { 1 + "1" }.must_raise TypeError
#
# This method of expectation-based testing is preferable to
# straight-expectation methods (on Object) because it stores its
# test context, bypassing our hacky use of thread-local variables.
#
# At some point, the methods on Object will be deprecated and then
# removed.
# NOTE: At some point, the methods on Object will be deprecated
# and then removed.
#
# It is also aliased to #value and #expect for your aesthetic
# pleasure:
#
# _(1 + 1).must_equal 2
# value(1 + 1).must_equal 2
# expect(1 + 1).must_equal 2

def _ value = nil, &block
Minitest::Expectation.new block || value, self
Expand Down

0 comments on commit 15ed8e4

Please sign in to comment.