diff --git a/Gemfile b/Gemfile index 2dac66f..af456cf 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,3 @@ source 'https://rubygems.org' -ruby '2.0.0' gem 'rspec', '~> 3.0.0.beta2' \ No newline at end of file diff --git a/lib/deaf_grandma.rb b/lib/deaf_grandma.rb index 83ad52a..b597863 100644 --- a/lib/deaf_grandma.rb +++ b/lib/deaf_grandma.rb @@ -10,7 +10,7 @@ def initialize def run! print_welcome - + loop do user_input = get_user_input p speak(user_input) @@ -19,13 +19,28 @@ def run! def speak(input) - - #Implement your code here <<<<<<<<< - + if input == "BYE" + handle_bye + elsif input == input.upcase + "NOT SINCE 1964!" + else + "SPEAK UP SONNY!" + end end private + def handle_bye + @bye_counter += 1 + if @bye_counter == 3 + p "SEE YOU LATER SONNY" + exit + else + + "" + end + end + def print_welcome puts "\nSpeak to your Grandmother: " end @@ -38,4 +53,4 @@ def get_user_input end #Uncomment this next line to run your script but BE SURE to comment it, before you try and run your tests. -#DeafGrandma.new.run! +# DeafGrandma.new.run! diff --git a/spec/deaf_grandma_spec.rb b/spec/deaf_grandma_spec.rb index cf09766..c59edc7 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 - end + # it "says 'SEE YOU LATER SONNY!' when we say BYE 3 times" do + # expect(script.speak("BYE")).to eq "SEE YOU LATER SONNY!" + # end end