MiniTest::Unit::TestCase
Define an ‘after’ action. Inherits the way normal methods should.
NOTE: type is ignored and is only there to make porting
easier.
Equivalent to MiniTest::Unit::TestCase#teardown.
# File minitest/spec.rb, line 148
def self.after type = :each, &block
raise "unsupported after type: #{type}" unless type == :each
define_inheritable_method :teardown, &block
end
Define a ‘before’ action. Inherits the way normal methods should.
NOTE: type is ignored and is only there to make porting
easier.
Equivalent to MiniTest::Unit::TestCase#setup.
# File minitest/spec.rb, line 136
def self.before type = :each, &block
raise "unsupported before type: #{type}" unless type == :each
define_inheritable_method :setup, &block
end
Define an expectation with name desc. Name gets morphed to a
proper test method name. For some freakish reason, people who write specs
don’t like class inheritence, so this goes way out of its way to make sure
that expectations aren’t inherited.
Hint: If you do want inheritence, use minitest/unit. You can mix and match between assertions and expectations as much as you want.
# File minitest/spec.rb, line 162
def self.it desc, &block
block ||= proc { skip "(no tests defined)" }
@specs ||= 0
@specs += 1
name = "test_%04d_%s" % [ @specs, desc.gsub(/\W+/, '_').downcase ]
define_method name, &block
classes(MiniTest::Spec).each do |mod|
mod.send :undef_method, name if mod.respond_to? name
end
end
See MiniTest::Assertions#assert_in_delta
# File minitest/spec.rb, line 185
See MiniTest::Assertions#assert_empty
# File minitest/spec.rb, line 189
See MiniTest::Assertions#assert_instance_of
# File minitest/spec.rb, line 193
See MiniTest::Assertions#assert_kind_of
# File minitest/spec.rb, line 197
See MiniTest::Assertions#assert_nil
# File minitest/spec.rb, line 201
See MiniTest::Assertions#assert_same
# File minitest/spec.rb, line 205
See MiniTest::Assertions#assert_in_delta
# File minitest/spec.rb, line 209
See MiniTest::Assertions#assert_in_epsilon
# File minitest/spec.rb, line 213
See MiniTest::Assertions#assert_equal
# File minitest/spec.rb, line 217
See MiniTest::Assertions#assert_includes
# File minitest/spec.rb, line 221
See MiniTest::Assertions#assert_match
# File minitest/spec.rb, line 225
See MiniTest::Assertions#assert_raises
# File minitest/spec.rb, line 229
See MiniTest::Assertions#assert_respond_to
# File minitest/spec.rb, line 233
See MiniTest::Assertions#assert_send
# File minitest/spec.rb, line 237
See MiniTest::Assertions#assert_throw
# File minitest/spec.rb, line 241
See MiniTest::Assertions#refute_in_delta
# File minitest/spec.rb, line 249
See MiniTest::Assertions#refute_empty
# File minitest/spec.rb, line 253
See MiniTest::Assertions#refute_instance_of
# File minitest/spec.rb, line 257
See MiniTest::Assertions#refute_kind_of
# File minitest/spec.rb, line 261
See MiniTest::Assertions#refute_nil
# File minitest/spec.rb, line 265
See MiniTest::Assertions#refute_same
# File minitest/spec.rb, line 269
See MiniTest::Assertions#refute_in_delta
# File minitest/spec.rb, line 273
See MiniTest::Assertions#refute_in_epsilon
# File minitest/spec.rb, line 277
See MiniTest::Assertions#refute_equal
# File minitest/spec.rb, line 281
See MiniTest::Assertions#refute_includes
# File minitest/spec.rb, line 285
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.