Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active November 10, 2017 01:33
Show Gist options
  • Save havenwood/23f8dab52adbe7ea3060 to your computer and use it in GitHub Desktop.
Save havenwood/23f8dab52adbe7ea3060 to your computer and use it in GitHub Desktop.
Explore Minitest::Assertions from the top level
require 'minitest'
# ##
# # Provide an incrementable `assertions` attr_accessor to use assertions
# # a la carte. Normally this would already be provided by Minitest::Runnable
# # but we want to play with assertions from the top level! \o/
module Minitest::Assertions
attr_writer :assertions
def assertions
@assertions ||= 0
end
end
include Minitest::Assertions
##
# Now assertions are available:
assert 42
#=> true
assert_in_delta 1.999, 2.0
#=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment