Skip to content

Instantly share code, notes, and snippets.

@minghz
Created January 1, 2020 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minghz/572ea510a514c0f0bcecd4f30307f18b to your computer and use it in GitHub Desktop.
Save minghz/572ea510a514c0f0bcecd4f30307f18b to your computer and use it in GitHub Desktop.
Making MiniTest work like RSpec - pt2
# you actually need the "minitest-hooks" gem to get this lib =_="
require 'minitest/hooks'
require 'minitest/autorun'
class ExtendedMinitest < Minitest::Test
extend MiniTest::Spec::DSL
include Minitest::Hooks # You need to add this to your test classes
end
class MyTest < ExtendedMinitest
before(:all) do
Heavy = Struct.new(:something, :takes, :of, :to)
@heavy_variable = Heavy.new('that', 'a lot', 'time', 'setup')
puts 'gets printed once only'
end
it { assert_equal 'that', @heavy_variable.something }
it { assert_equal 'a lot', @heavy_variable.takes }
it { assert_equal 'time', @heavy_variable.of }
it { assert_equal 'setup', @heavy_variable.to }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment