This is an example of writing parameterized subject
blocks in MiniTest.
It also works with let
declarations.
describe DiceRoller do | |
describe "initialization" do | |
subject { ->(*dice) { DiceRoller.new(*dice) } } | |
it "accepts a single die" do | |
die = Die.new(6) | |
subject[die].dice.count.must_equal 1 | |
end | |
it "accepts multiple dice" do | |
die1, die2 = Array.new(2) { Die.new(6) } | |
subject[die1, die2].dice.count.must_equal 2 | |
end | |
end | |
end |
This is an example of writing parameterized subject
blocks in MiniTest.
It also works with let
declarations.