Skip to content

Instantly share code, notes, and snippets.

@biscuitvile
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save biscuitvile/e8ca51942e6bc564462e to your computer and use it in GitHub Desktop.

Select an option

Save biscuitvile/e8ca51942e6bc564462e to your computer and use it in GitHub Desktop.
Custom Minitest Assertion
module MiniTest::Assertions
def assert_destroyed(record)
assert_raises(ActiveRecord::RecordNotFound) { record.class.find(record.id) }
end
def refute_destroyed(record)
assert_nothing_raised { record.class.find(record.id) }
end
end
ActiveRecord::Base.infect_an_assertion :assert_destroyed, :must_be_destroyed, :unary
ActiveRecord::Base.infect_an_assertion :refute_destroyed, :wont_be_destroyed, :unary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment