Skip to content

Instantly share code, notes, and snippets.

@pbevin
Created May 29, 2010 16:50
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 pbevin/418370 to your computer and use it in GitHub Desktop.
Save pbevin/418370 to your computer and use it in GitHub Desktop.
class L
end
class Module
def has_logging()
class_eval {
log = L.new
define_method(:log) do
log
end
}
end
end
describe "logging" do
before (:each) do
@c_base = Class.new do
has_logging
end
@c_derived_without_logging = Class.new(@c_base) do
end
@c_derived_with_logging = Class.new(@c_base) do
has_logging
end
end
it "should have distinct logging for subclasses" do
# Fails!
@c_derived_with_logging.new.log.should_not == @c_base.new.log
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment