-
-
Save juliocesar/832952 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 self.included base | |
base.send :attr_reader, :visible | |
end | |
def activate | |
@visible = false | |
end | |
def deactivate | |
@visible = true | |
end | |
def visible? | |
@visible | |
end | |
end | |
class Person; end | |
if $0 =~ /spec/ | |
describe "invisibility" do | |
before do | |
Person.send :include, Invisibility | |
@bob = Person.new | |
end | |
subject { @bob } | |
context 'when given to a Person' do | |
it 'creates a #visible? method' do | |
@bob.should respond_to :visible? | |
end | |
end | |
context 'activating' do | |
specify { should respond_to :activate } | |
it '#activate should make the person invisible' do | |
subject.activate | |
subject.should_not be_visible | |
end | |
end | |
context 'deactivating' do | |
specify { should respond_to :deactivate } | |
it '#deactivate should make a person visible' do | |
subject.deactivate | |
subject.should be_visible | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment