Last active
December 25, 2015 23:29
-
-
Save JoshBrodieNZ/7057197 to your computer and use it in GitHub Desktop.
Reimplement a user-customisable version of the test class for codewars.com
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
class Class | |
def method_added(method_name) | |
puts "#{method_name} to #{self}" | |
if method_name == :after | |
newtest = Test.dup | |
Object.send(:remove_const, :Test) | |
Object.const_set(:Test, newtest) | |
Test.module_eval do | |
def self.expect(*args) | |
puts "LOOK, MA. I CAN CHANGE IT." | |
super | |
end | |
end | |
Test.freeze | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Include in self-expect args[0] = true and super(args) to INJECT VICTORY INTO THE HEART OF TEST