Skip to content
This repository was archived by the owner on Nov 16, 2018. It is now read-only.

Using MiniTest

Ryan Platte edited this page Jul 10, 2014 · 14 revisions

You can also use minitest assert methods by defining your own World block:

Minitest 5

require 'minitest/spec'

class MinitestWorld
  extend Minitest::Assertions
  attr_accessor :assertions

  def initialize
    self.assertions = 0
  end
end

World do
  MinitestWorld.new
end

Older versions

require 'mini/test'

World do |world|
  world.extend(Mini::Test::Assertions)
  world
end

If it doesn’t work, try this one:

require 'minitest/unit'

World do
  extend Mini::Test::Assertions
end

Or

require 'minitest/unit'
World(MiniTest::Assertions)

Also, if you wanted to use MiniTest::Spec, the snippet would look like this:

require 'minitest/spec'
World(MiniTest::Assertions)
MiniTest::Spec.new(nil)

Also see the minitest cheat sheet here

Clone this wiki locally