Skip to content

Instantly share code, notes, and snippets.

@knzconnor
Created July 22, 2009 20:13
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 knzconnor/152242 to your computer and use it in GitHub Desktop.
Save knzconnor/152242 to your computer and use it in GitHub Desktop.
module MethodVisibility
#mocking out super calls is tricky, so here is a hack to get around it.
def hide_method(method, replacement = Proc.new(){})
self.send :alias_method, :old_method, method
self.send :define_method, method, replacement
begin
yield
ensure #otherwise other tests get screwed up if an assertion fails inside block
self.send :alias_method, method, :old_method
self.send :remove_method, :old_method
end
end
alias replace_method hide_method
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment