Skip to content

Instantly share code, notes, and snippets.

@carlhuda
Created February 27, 2010 02:31
Show Gist options
  • Save carlhuda/316416 to your computer and use it in GitHub Desktop.
Save carlhuda/316416 to your computer and use it in GitHub Desktop.
class MockController
def url_for(options)
super(options)
end
end
module ActualUrlFor
def url_for(options)
options.values.join("/")
end
end
klass = MockController.clone
klass.class_eval { include ActualUrlFor }
p klass.new.url_for(:controller => "omg", :action => "omgomg")
# testing.rb:3:in `url_for': super: no superclass method `new' for #<#<Class:0x00000100865000>:0x00000100864f10> (NoMethodError)
# from testing.rb:15:in `<main>'
class MockController
def url_for(options)
super(options)
end
end
module ActualUrlFor
def url_for(options)
options.values.join("/")
end
end
klass = MockController.clone
klass.class_eval { include ActualUrlFor }
obj = klass.new
obj.to_s
p obj.url_for(:controller => "omg", :action => "omgomg")
# testing.rb:3:in `url_for': super: no superclass method `to_s' for #<#<Class:0x00000100864e70>:0x00000100864d80> (NoMethodError)
# from testing.rb:17:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment