From ac70cb80c6eb4663f7310849661ac7502678dbb0 Mon Sep 17 00:00:00 2001 From: Josh Kapsch Date: Thu, 26 Apr 2018 16:22:11 -0400 Subject: [PATCH 1/5] Updated gemfile as was unable to bundle items with ruby 2.2 --- Gemfile | 2 +- Gemfile.lock | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 2dac66f..d684e12 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 diff --git a/Gemfile.lock b/Gemfile.lock index dfd2ba5..4477308 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -20,3 +20,9 @@ PLATFORMS DEPENDENCIES rspec (~> 3.0.0.beta2) + +RUBY VERSION + ruby 2.2.9p480 + +BUNDLED WITH + 1.16.1 From 67cbe6f97403d7bb49aa1811c2545fd0b2de9f48 Mon Sep 17 00:00:00 2001 From: Josh Kapsch Date: Thu, 26 Apr 2018 16:23:21 -0400 Subject: [PATCH 2/5] Updated readme to use the bundler installed version of rspec --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7fb2718..0c4f90b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Enjoy! ## Super Fizz Buzz Instructions -Clone the repository, navigate to the project directory and run `rspec spec/fizzbuzz_spec.rb`. If you're using RubyMine, you may have to complete different steps to run the tests. When you run the tests, they should initially fail. Your goal is to make the tests pass by modifying the `run` method in the `lib/fizz_buzz.rb` file. It should accept a number and return the following: +Clone the repository, navigate to the project directory and run `bundle exec rspec spec/fizzbuzz_spec.rb`. If you're using RubyMine, you may have to complete different steps to run the tests. When you run the tests, they should initially fail. Your goal is to make the tests pass by modifying the `run` method in the `lib/fizz_buzz.rb` file. It should accept a number and return the following: - Return "Fizz" if the number is divisible by 3 - Return "Buzz" if the number is divisible by 5 From f0c821ae14d3f4e949475e307870b6e99dfe6e72 Mon Sep 17 00:00:00 2001 From: Josh Kapsch Date: Thu, 26 Apr 2018 16:24:14 -0400 Subject: [PATCH 3/5] Implemented fizzbuzz and tests --- lib/fizzbuzz.rb | 12 +++++++++--- spec/fizzbuzz_spec.rb | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/fizzbuzz.rb b/lib/fizzbuzz.rb index 86f9def..351651f 100644 --- a/lib/fizzbuzz.rb +++ b/lib/fizzbuzz.rb @@ -1,9 +1,15 @@ class SuperFizzBuzz def run(input) - - #Implement your code here - + if input % 5 == 0 && input % 3 == 0 + "FizzBuzz" + elsif input % 3 == 0 + "Fizz" + elsif input % 5 == 0 + "Buzz" + else + input # return the original number if not divisible by either + end end end diff --git a/spec/fizzbuzz_spec.rb b/spec/fizzbuzz_spec.rb index cfda46b..a78aa0a 100644 --- a/spec/fizzbuzz_spec.rb +++ b/spec/fizzbuzz_spec.rb @@ -9,14 +9,14 @@ 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(7)).to eq 7 end end From 52c55f2b9b1b93f09d13cf049e37077ca79da682 Mon Sep 17 00:00:00 2001 From: Josh Kapsch Date: Thu, 26 Apr 2018 16:51:23 -0400 Subject: [PATCH 4/5] Implemented the deaf grandma problem set --- lib/deaf_grandma.rb | 10 +++++++--- spec/deaf_grandma_spec.rb | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/deaf_grandma.rb b/lib/deaf_grandma.rb index 83ad52a..84a9d97 100644 --- a/lib/deaf_grandma.rb +++ b/lib/deaf_grandma.rb @@ -19,9 +19,13 @@ def run! def speak(input) - - #Implement your code here <<<<<<<<< - + if input == "BYE!" + "BYE!" + elsif input == input.upcase && input.end_with?("!") + "NOT SINCE 1964!" + else + "SPEAK UP SONNY!" + end end private diff --git a/spec/deaf_grandma_spec.rb b/spec/deaf_grandma_spec.rb index cf09766..776b4c5 100644 --- a/spec/deaf_grandma_spec.rb +++ b/spec/deaf_grandma_spec.rb @@ -9,10 +9,10 @@ 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 + expect(script.speak("BYE!")).to eq "BYE!" end end From 6e04c589ed2ed16dc565cdc9c9c0c82862f93392 Mon Sep 17 00:00:00 2001 From: Josh Kapsch Date: Thu, 26 Apr 2018 17:11:12 -0400 Subject: [PATCH 5/5] Fixed the deaf grandma goodbye logic --- lib/deaf_grandma.rb | 12 ++++++++---- spec/deaf_grandma_spec.rb | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/deaf_grandma.rb b/lib/deaf_grandma.rb index 84a9d97..473bf63 100644 --- a/lib/deaf_grandma.rb +++ b/lib/deaf_grandma.rb @@ -19,12 +19,16 @@ def run! def speak(input) - if input == "BYE!" + said_bye = input.start_with?("BYE") + + @bye_counter += 1 if said_bye + + if said_bye && @bye_counter > 2 "BYE!" - elsif input == input.upcase && input.end_with?("!") - "NOT SINCE 1964!" + elsif input == input.upcase + "NOT SINCE 1964!" else - "SPEAK UP SONNY!" + "SPEAK UP SONNY!" end end diff --git a/spec/deaf_grandma_spec.rb b/spec/deaf_grandma_spec.rb index 776b4c5..f9f374f 100644 --- a/spec/deaf_grandma_spec.rb +++ b/spec/deaf_grandma_spec.rb @@ -9,10 +9,12 @@ end it "says 'NOT SINCE 1964!' when we yell" do - expect(script.speak("HI GRANDMA!")).to eq "NOT SINCE 1964!" + expect(script.speak("HI GRANDMA")).to eq "NOT SINCE 1964!" end it "EXTRA CREDIT: How would you test yelling BYE?" do + expect(script.speak("BYE!")).to eq "NOT SINCE 1964!" + expect(script.speak("BYE!")).to eq "NOT SINCE 1964!" expect(script.speak("BYE!")).to eq "BYE!" end end