Module: Minitest::ShouldJustWork::TestHelpers

Defined in:
lib/minitest/should_just_work.rb,
sig/minitest/should_just_work.rbs

Overview

Prepended to Minitest::Test so every test hands itself to ShouldJustWork before it runs, and so tests gain the #msg and #otherwise helpers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#msg(string = nil) ⇒ String?

Reads the failure message waiting to be attached to the next comparison, or sets it when given one.

Parameters:

  • string (String, nil) (defaults to: nil)

Returns:

  • (String, nil)


161
162
163
164
# File 'lib/minitest/should_just_work.rb', line 161

def msg(string = nil)
  self.msg = string if string
  @msg
end

Instance Method Details

#before_setupvoid

This method returns an undefined value.



154
155
156
157
# File 'lib/minitest/should_just_work.rb', line 154

def before_setup
  Should.init self
  super
end

#otherwise(message) ⇒ String?

Reads better than #msg in front of an assertion.

Parameters:

  • message (String)

Returns:

  • (String, nil)


169
# File 'lib/minitest/should_just_work.rb', line 169

def otherwise(message) = msg(message)