Last active
September 7, 2018 11:21
-
-
Save tbuehlmann/ced1e747098a5346595962f75579f187 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class A | |
def self.foo | |
end | |
end | |
class B < A | |
end | |
mock_a = MiniTest::Mock.new | |
mock_b = MiniTest::Mock.new | |
A.stub(:foo, mock_a) do | |
B.stub(:foo, mock_b) { } | |
end | |
A.method(:foo).source # => " def self.foo\n end\n" | |
B.method(:foo).source # => " metaclass.send :define_method, name do |*args, &blk|\n if val_or_callable.respond_to? :call then\n val_or_callable.call(*args, &blk)\n else\n blk.call(*block_args) if blk\n val_or_callable\n end\n end\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment