Skip to content

Instantly share code, notes, and snippets.

@jamesmartin
Created February 17, 2011 23:04
Show Gist options
  • Save jamesmartin/832937 to your computer and use it in GitHub Desktop.
Save jamesmartin/832937 to your computer and use it in GitHub Desktop.
Testing the Invisibility superpower by creating a sort of dumb target class 'Person' to give the power to in the test.
module Invisibility
def activate
@visible = false
end
def deactivate
@visible = true
end
end
class Person
attr_reader :visible
def initialize
@visible = true
end
def visible?
@visible
end
end
describe "invisibility" do
it "can be activated" do
Person.send :include, Invisibility
bob = Person.new
bob.should respond_to :activate
bob.activate
bob.should_not be_visible
end
it "can be deactivated" do
Person.send :include, Invisibility
bob = Person.new
bob.should respond_to :deactivate
bob.deactivate
bob.should be_visible
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment