Around block for minitest 5.X.
Alternative for setup/teardown dance.
gem install minitest-around
require 'minitest/autorun' require 'minitest/around/unit' require 'thread' class MutexTest < Minitest::Test def around(&block) Mutex.new.synchronize(&block) end def test_synchronized # ... end end
require 'minitest/autorun' require 'minitest/around/spec' require 'tmpdir' describe "inside new directory" do around do |test| Dir.mktmpdir do |dir| @dir = dir Dir.chdir(dir) do test.call end end end it "is in new directory" do assert_equal @dir, Dir.pwd.sub("/private/var/", "/var/") end end
Multiple before/after blocks
Minitest-around also enables the use of multiple before/after blocks, which normally don't work in minitest.
- Test bodies won't be run if you don't test.call inside +around+.
- around runs inside a Fiber, so use
Minitest 5.X only
minitest-around currently supports only
Please see the mt4 branch
minitest 4.7.X support.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request
bundle exec rake test
edit lib/minitest/around/version.rb git commit rake release