Last active
November 10, 2017 01:33
-
-
Save havenwood/23f8dab52adbe7ea3060 to your computer and use it in GitHub Desktop.
Explore Minitest::Assertions from the top level
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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