Created
July 23, 2011 20:22
-
-
Save tenderlove/1101844 to your computer and use it in GitHub Desktop.
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/autorun' | |
class MyTest < MiniTest::Unit::TestCase | |
class SomeClass | |
def calls_takes_args | |
takes_args "hello world" | |
end | |
private | |
def takes_args arg | |
puts "i was called" | |
end | |
end | |
def setup | |
#pretend this instance came from somewhere else | |
@instance = SomeClass.new | |
end | |
def test_immediate_check_args | |
tc = self | |
@instance.extend Module.new { | |
define_method(:takes_args) { |arg| | |
tc.assert_equal 'hello world', arg | |
super(arg) | |
} | |
} | |
@instance.calls_takes_args | |
end | |
def test_check_args_later | |
args = [] | |
@instance.extend Module.new { | |
define_method(:takes_args) { |arg| | |
args << arg | |
super(arg) | |
} | |
} | |
@instance.calls_takes_args | |
assert_equal ['hello world'], args | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment