Created
July 10, 2015 20:43
-
-
Save ethnt/c8f76a2d8aa26b0c4d27 to your computer and use it in GitHub Desktop.
Include arbitrary modules with Ruby.
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
# Use this class to test an arbitrary module. | |
class Harness | |
def initialize(_module) | |
self.class.include _module | |
end | |
end | |
### | |
# The module being tested | |
module ToBeTested | |
def foo | |
"foo!" | |
end | |
end | |
harness = Harness.new(ToBeTested) | |
harness.foo # => "foo!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment