Reputation: 1414
What would be the best way of testing a Ruby block with minitest. Rspec seems to have a set of yield matchers. Is there something similar in minitest
Upvotes: 0
Views: 1067
Reputation: 21820
RSpec's yield matchers are simple syntactic sugar over a fairly simple way of testing blocks.
So, you can do something like this:
block_called = false
do_something { block_called = true }
assert_true block_called
Alternately, if you like the syntax and failure output of rspec-expectations, you can easily use it with minitest (or any other testing framework); I blogged about this if you want the nitty-gritty details.
Upvotes: 4