From f79cb8dee796b897d7c3399ee0f7e61a2c8b3511 Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Fri, 7 Feb 2025 15:38:46 -0600 Subject: [PATCH 1/5] First commit --- lib/shelter.rb | 11 ++++++++++- spec/shelter_spec.rb | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/shelter.rb b/lib/shelter.rb index 5bb89e6..d3a91f0 100644 --- a/lib/shelter.rb +++ b/lib/shelter.rb @@ -1,2 +1,11 @@ class Shelter -end \ No newline at end of file + attr_reader :name, :capacity :pets + + def initialize(name, capacity, pets) + @name = name + @capacity = capacity + @pets = [] + end +end + + diff --git a/spec/shelter_spec.rb b/spec/shelter_spec.rb index 8d3b01d..68aba67 100644 --- a/spec/shelter_spec.rb +++ b/spec/shelter_spec.rb @@ -5,22 +5,22 @@ # 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 From 6834fff874a881734ddbdcde935117301f42c7d1 Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Fri, 7 Feb 2025 15:44:56 -0600 Subject: [PATCH 2/5] fix arg --- lib/shelter.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/shelter.rb b/lib/shelter.rb index d3a91f0..cbe3d56 100644 --- a/lib/shelter.rb +++ b/lib/shelter.rb @@ -1,11 +1,10 @@ class Shelter - attr_reader :name, :capacity :pets + attr_reader :name, :capacity, :pets - def initialize(name, capacity, pets) + def initialize(name, capacity) @name = name @capacity = capacity @pets = [] end end - From c742e7516cf3281055d7ee1b3d83b297ef144ce1 Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Fri, 7 Feb 2025 16:18:22 -0600 Subject: [PATCH 3/5] add iteration two --- lib/shelter.rb | 14 +++++++++++++- spec/shelter_spec.rb | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/shelter.rb b/lib/shelter.rb index cbe3d56..3443fe4 100644 --- a/lib/shelter.rb +++ b/lib/shelter.rb @@ -6,5 +6,17 @@ def initialize(name, capacity) @capacity = capacity @pets = [] end -end + def add_pet(name) + pets << name + end + + def call_pets + call_pets = [] + pets.each do |name| + call_pets << "#{name}!" + end + + call_pets + end +end \ No newline at end of file diff --git a/spec/shelter_spec.rb b/spec/shelter_spec.rb index 68aba67..fa06d98 100644 --- a/spec/shelter_spec.rb +++ b/spec/shelter_spec.rb @@ -28,7 +28,7 @@ # 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') @@ -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') From c79a3ed46ada7704ad75c4fd8ee7e06dcc92ad27 Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Fri, 7 Feb 2025 16:30:51 -0600 Subject: [PATCH 4/5] add iteration three --- spec/shelter_spec.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/shelter_spec.rb b/spec/shelter_spec.rb index fa06d98..1946f9b 100644 --- a/spec/shelter_spec.rb +++ b/spec/shelter_spec.rb @@ -50,4 +50,18 @@ expect(shelter.call_pets).to eq(['Salem!', 'Beethoven!', 'Spot!', 'Jonesy!']) end end -end \ No newline at end of file + + # 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') + shelter.add_pet('Spot') + shelter.add_pet('Jonesy') + + expect(shelter.over_capacity?).to eq(true) + end + end +end + From fa0caed6d9daddf89ab77b3791068e768c7c11a2 Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Fri, 7 Feb 2025 16:39:33 -0600 Subject: [PATCH 5/5] created test for over_capacity --- lib/shelter.rb | 3 ++- spec/shelter_spec.rb | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/shelter.rb b/lib/shelter.rb index 3443fe4..3ba5dee 100644 --- a/lib/shelter.rb +++ b/lib/shelter.rb @@ -16,7 +16,8 @@ def call_pets pets.each do |name| call_pets << "#{name}!" end - call_pets end + + def over_capacity end \ No newline at end of file diff --git a/spec/shelter_spec.rb b/spec/shelter_spec.rb index 1946f9b..4bccda3 100644 --- a/spec/shelter_spec.rb +++ b/spec/shelter_spec.rb @@ -57,6 +57,9 @@ 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')