Last active
March 28, 2017 23:46
-
-
Save phluid61/b3b22ede9f72350d1cb374de1ec2d97b to your computer and use it in GitHub Desktop.
How to unit test module methods
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 'test/unit' | |
$VERBOSE = true | |
#require 'a' | |
module A | |
extend self | |
def add(x, y) | |
x + y | |
end | |
end | |
#--- | |
class Test_A < Test::Unit::TestCase | |
def test_add | |
assert_equal( A.add(3, 1), 4 ) | |
end | |
end |
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
$ ruby test_a.rb | |
Loaded suite flarv | |
Started | |
. | |
Finished in 0.001174862 seconds. | |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications | |
100% passed | |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
851.16 tests/s, 851.16 assertions/s | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment