Skip to content

Instantly share code, notes, and snippets.

@phluid61
Last active March 28, 2017 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phluid61/b3b22ede9f72350d1cb374de1ec2d97b to your computer and use it in GitHub Desktop.
Save phluid61/b3b22ede9f72350d1cb374de1ec2d97b to your computer and use it in GitHub Desktop.
How to unit test module methods
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
$ 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