minitest-around 
Around block for minitest.
Alternative for setup/teardown dance.
Installation
gem install minitest-around
Usage
Unit tests
require 'minitest/autorun'
require 'minitest/around/unit'
require 'thread'
class MutexTest < MiniTest::Unit::TestCase
def around(&block)
Mutex.new.synchronize(&block)
end
def test_synchronized
# ...
end
end
class PassArgsTest < MiniTest::Unit::TestCase
def around
yield 1, 2
end
def test_passes_args(a, b)
assert_equal 3, a + b
end
end
Spec
require 'minitest/autorun'
require 'minitest/around/spec'
require 'thread'
describe "Mutex" do
around do |test|
Mutex.new.synchronize(&test)
end
it "synchronized" do
# ...
end
describe "pass args" do
around do
# No block arg "test",
[ 1, 2 ]
end
it "passes args" do |a, b|
(a + b).must_equal 3
end
end
end
Caveats
Test bodies won't be run if you don't yield inside around.
Contributing
-
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
Test
bundle exec rake test
Release
edit lib/minitest/around/version.rb
rake release