Skip to content

Instantly share code, notes, and snippets.

@minghz
Created January 1, 2020 05:52
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/2d1c28dc0dccbb558993670cfaafda9b to your computer and use it in GitHub Desktop.
Save minghz/2d1c28dc0dccbb558993670cfaafda9b to your computer and use it in GitHub Desktop.
Making MiniTest work like RSpec - pt3
require 'minitest/hooks'
require 'minitest/autorun'
class ActiveSupport::TestCase
extend MiniTest::Spec::DSL
end
class ActionDispatch::IntegrationTest
extend MiniTest::Spec::DSL
end
class MyTest < ActiveSupport::TestCase
include Minitest::Hooks # You need to add this to your test classes
before(:all) do
@heavy_variable = HeavyThing.create!(
something: 'that',
takes: 'a lot',
of: 'time',
to: 'setup'
)
end
after(:all) do
@heavy_variable.destroy!
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