Skip to content

Instantly share code, notes, and snippets.

@brycelambert
Created October 4, 2013 03:56
Show Gist options
  • Save brycelambert/6820754 to your computer and use it in GitHub Desktop.
Save brycelambert/6820754 to your computer and use it in GitHub Desktop.
HappiTails Spec
require 'spec_helper'
require_relative '../Lab/animal'
require_relative '../Lab/person'
require_relative '../Lab/main'
require_relative '../Lab/shelter'
describe Shelter do
it "should have a method called new_client" do
should respond_to :new_client
end
it "should have a method called accept_animal" do
should respond_to :accept_animal
end
it "should have a method called remove_animal" do
should respond_to :remove_animal
end
subject { Shelter.new('HappiTails', '10 east 21st Street') }
its(:name) { should eq 'HappiTails'}
its(:address) { should eq '10 east 21st Street'}
it 'should include new animals in its animal hash' do
subject.accept_animal(Animal.new('Tassy', 3, 'male', 'Dog'))
subject.animals.should include 'Tassy'
end
end
describe Person do
it "should have a method called adopt" do
should respond_to :adopt
end
it "should have a method called accept_animal" do
should respond_to :adopt
end
it "should have a method called give_up" do
should respond_to :give_up
end
subject { Person.new('tom', 42, 2) }
its(:name) { should eq 'tom'}
its(:age) { should eq 42}
its(:num_pets) { should eq 2}
it 'should increase animal count when adopt method is called' do
subject.adopt(Animal.new('Tassy', 3, 'male', 'Dog'))
subject.num_pets.should eq 3
end
it 'should include new animals in its animal hash' do
subject.adopt(Animal.new('Tassy', 3, 'male', 'Dog'))
subject.pets.should include 'Tassy'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment