Module: Minitest::Spec::DSL::InstanceMethods

Defined in:
lib/minitest/spec.rb

Overview

Rdoc… why are you so dumb?

Instance Method Summary collapse

Instance Method Details

#_(value = nil, &block) ⇒ Object Also known as: value, expect

Takes a value or a block and returns a value monad that has all of Expectations methods available to it.

_(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.

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


323
324
325
# File 'lib/minitest/spec.rb', line 323

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

#before_setupObject

:nodoc:



330
331
332
333
# File 'lib/minitest/spec.rb', line 330

def before_setup # :nodoc:
  super
  Thread.current[:current_spec] = self
end