Created
March 5, 2012 21:21
-
-
Save russ/1981185 to your computer and use it in GitHub Desktop.
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
class Hero | |
attr_reader :hp | |
def initialize | |
@hp = 100 | |
end | |
def hit!(force) | |
@hp -= force | |
end | |
def heal!(amount) | |
@hp += amount | |
end | |
end | |
describe Hero do | |
subject { Hero.new } | |
it "should lower hp when they're hit" do | |
subject.hit!(10) | |
subject.hp.should == 90 | |
end | |
it "should raise hp when they heal" do | |
subject.heal!(10) | |
subject.hp.should == 110 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment