Skip to content

Instantly share code, notes, and snippets.

@nwjsmith
Created September 26, 2011 18:23
Show Gist options
  • Save nwjsmith/1242954 to your computer and use it in GitHub Desktop.
Save nwjsmith/1242954 to your computer and use it in GitHub Desktop.
require 'rspec'
module Evil
def defn(method_name)
class_eval <<-METHOD, __FILE__, __LINE__ + 1
def #{method_name}
end
METHOD
end
end
class Bob
extend Evil
defn :foo
end
class Alice
extend Evil
defn :bar
end
describe Alice do
it { should respond_to :bar }
it { should_not respond_to :foo }
end
describe Bob do
it { should respond_to :foo }
it { should_not respond_to :bar }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment