I want to use an assert to raise an error within a rake task.
the_index = items.index(some_item)
assert_not_nil the_index, "Lookup failed for the following item: " + some_item
I get undefined method assert_not_nil
. Can I include the assertions file in my rake task? How?
Is this a best practice, or is there a better way to do it?
Working in Ruby 1.9.2.
You can actually use assertions wherever you want.
require "minitest/unit"
include MiniTest::Assertions # all assertions are in this module
refute_nil @ivar, "An instance variable should not be nil here!"
But why would you do that? Raise meaningful exceptions yourself instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With