Created
February 17, 2011 23:04
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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