Created
January 1, 2020 04:39
-
-
Save minghz/572ea510a514c0f0bcecd4f30307f18b to your computer and use it in GitHub Desktop.
Making MiniTest work like RSpec - pt2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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