Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zach Johnson #10

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/shelter.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
class Shelter
attr_reader :name, :capacity, :pets

def initialize(name, capacity)
@name = name
@capacity = capacity
@pets = []
end

def add_pet(name)
pets << name
end

def call_pets
call_pets = []
pets.each do |name|
call_pets << "#{name}!"
end
call_pets
end

def over_capacity
end
31 changes: 24 additions & 7 deletions spec/shelter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@

# Iteration 1
describe '#initialize' do
xit 'is a Shelter' do
it 'is a Shelter' do
shelter = Shelter.new('Denver Animal Shelter', 5)
expect(shelter).to be_a(Shelter)
end

xit 'can read the name' do
it 'can read the name' do
shelter = Shelter.new('Denver Animal Shelter', 5)
expect(shelter.name).to eq('Denver Animal Shelter')
end

xit 'can read the capacity' do
it 'can read the capacity' do
shelter = Shelter.new('Denver Animal Shelter', 5)
expect(shelter.capacity).to eq(5)
end

xit 'has no pets by default' do
it 'has no pets by default' do
shelter = Shelter.new('Denver Animal Shelter', 5)
expect(shelter.pets).to eq []
end
end

# Iteration 2
describe '#add_pet' do
xit 'returns a list of pets' do
it 'returns a list of pets' do
shelter = Shelter.new('Denver Animal Shelter', 5)
shelter.add_pet('Salem')
shelter.add_pet('Beethoven')
Expand All @@ -40,7 +40,7 @@
end

describe '#call_pets' do
xit 'returns a list of names with exclamation points appended' do
it 'returns a list of names with exclamation points appended' do
shelter = Shelter.new('Denver Animal Shelter', 5)
shelter.add_pet('Salem')
shelter.add_pet('Beethoven')
Expand All @@ -50,4 +50,21 @@
expect(shelter.call_pets).to eq(['Salem!', 'Beethoven!', 'Spot!', 'Jonesy!'])
end
end
end

# Iteration 3
describe '#over_capacity?' do
it 'tells if shelter is over capacity' do
shelter = Shelter.new('Denver Animal Shelter', 3)
shelter.add_pet('Salem')
shelter.add_pet('Beethoven')

expect(shelter.over_capacity?).to eq(false)

shelter.add_pet('Spot')
shelter.add_pet('Jonesy')

expect(shelter.over_capacity?).to eq(true)
end
end
end