From 56f47e6508b4bffea8d8672037c593c8e23de6f0 Mon Sep 17 00:00:00 2001 From: Andrew Bonner Date: Thu, 10 May 2018 15:31:08 -0400 Subject: [PATCH 1/3] Pass grandma tests. --- Gemfile | 4 ++-- lib/deaf_grandma.rb | 14 +++++++++++--- spec/deaf_grandma_spec.rb | 8 +++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 2dac66f..e70eaf4 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -ruby '2.0.0' +# ruby '2.0.0' -gem 'rspec', '~> 3.0.0.beta2' \ No newline at end of file +gem 'rspec', '~> 3.0.0.beta2' diff --git a/lib/deaf_grandma.rb b/lib/deaf_grandma.rb index 83ad52a..d4fcc4d 100644 --- a/lib/deaf_grandma.rb +++ b/lib/deaf_grandma.rb @@ -5,7 +5,7 @@ class DeafGrandma def initialize - @bye_counter = 0 + @bye_counter = 0 end def run! @@ -19,9 +19,17 @@ def run! def speak(input) + if input == "BYE" + @bye_counter += 1 + end - #Implement your code here <<<<<<<<< - + if input != input.upcase + "SPEAK UP SONNY!" + elsif @bye_counter == 3 + "SEE YOU LATER SONNY!" + else + "NOT SINCE 1964!" + end end private diff --git a/spec/deaf_grandma_spec.rb b/spec/deaf_grandma_spec.rb index cf09766..0722043 100644 --- a/spec/deaf_grandma_spec.rb +++ b/spec/deaf_grandma_spec.rb @@ -7,12 +7,14 @@ it "says 'SPEAK UP SONNY!' when we speak regularly" do expect(script.speak("Hi Grandma")).to eq "SPEAK UP SONNY!" end - + it "says 'NOT SINCE 1964!' when we yell" do - #implement your test here + expect(script.speak("HI GRANDMA")).to eq "NOT SINCE 1964!" end it "EXTRA CREDIT: How would you test yelling BYE?" do - #implement your test here + script.speak("BYE") + script.speak("BYE") + expect(script.speak("BYE")).to eq("SEE YOU LATER SONNY!") end end From c1931994a7b902109916f891b03fd3a043a447d3 Mon Sep 17 00:00:00 2001 From: Andrew Bonner Date: Thu, 10 May 2018 15:33:30 -0400 Subject: [PATCH 2/3] Write FizzBuzz tests. --- lib/fizzbuzz.rb | 6 +++--- spec/fizzbuzz_spec.rb | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/fizzbuzz.rb b/lib/fizzbuzz.rb index 86f9def..335e54c 100644 --- a/lib/fizzbuzz.rb +++ b/lib/fizzbuzz.rb @@ -1,9 +1,9 @@ class SuperFizzBuzz def run(input) - - #Implement your code here - + if input % 3 == 0 + "Fizz" + end end end diff --git a/spec/fizzbuzz_spec.rb b/spec/fizzbuzz_spec.rb index cfda46b..ce6a8b1 100644 --- a/spec/fizzbuzz_spec.rb +++ b/spec/fizzbuzz_spec.rb @@ -7,16 +7,16 @@ it "returns 'Fizz' when my input is divisible by 3" do expect(script.run(3)).to eq "Fizz" end - + it "returns 'Buzz' when my input is divisible by 5" do - #implement your test here + expect(script.run(5)).to eq "Buzz" end it "returns 'FizzBuzz' when input is divisible by 3 & 5" do - #implement your test here + expect(script.run(15)).to eq "FizzBuzz" end - + it "returns the input number when input isn't divisible by 3, 5, or both" do - #implement your test here + expect(script.run(4)).to eq 4 end end From 70a84acbe97259d0c4a926b3e4cf1bb926ef04b3 Mon Sep 17 00:00:00 2001 From: Andrew Bonner Date: Thu, 10 May 2018 15:42:10 -0400 Subject: [PATCH 3/3] Pass FizzBuzz tests. --- lib/fizzbuzz.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/fizzbuzz.rb b/lib/fizzbuzz.rb index 335e54c..0addfe6 100644 --- a/lib/fizzbuzz.rb +++ b/lib/fizzbuzz.rb @@ -1,8 +1,14 @@ class SuperFizzBuzz def run(input) - if input % 3 == 0 + if input % 3 == 0 && input % 5 == 0 + "FizzBuzz" + elsif input % 3 == 0 "Fizz" + elsif input % 5 == 0 + "Buzz" + else + input end end