Skip to content
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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://rubygems.org'
ruby '2.0.0'
ruby '2.2.9'

gem 'rspec', '~> 3.0.0.beta2'
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ PLATFORMS

DEPENDENCIES
rspec (~> 3.0.0.beta2)

RUBY VERSION
ruby 2.2.9p480

BUNDLED WITH
1.16.1
26 changes: 25 additions & 1 deletion lib/deaf_grandma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,26 @@ def run!
loop do
user_input = get_user_input
p speak(user_input)
exit if @bye_counter == 3
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since @bye_counter is compared with 3 in two places, consider a new instance method called exiting?.

end
end


def speak(input)
if input == input.upcase

if input == "BYE"
@bye_counter += 1
else
@bye_counter = 0
end

#Implement your code here <<<<<<<<<
@bye_counter == 3 ? byes_response : yell_response

else
@bye_counter = 0
soft_speech_response
end
end

private
Expand All @@ -35,6 +47,18 @@ def get_user_input
gets.chomp
end

def soft_speech_response
"SPEAK UP SONNY!"
end

def byes_response
"SEE YOU LATER SONNY!"
end

def yell_response
"NOT SINCE 1964!"
end

end

#Uncomment this next line to run your script but BE SURE to comment it, before you try and run your tests.
Expand Down
8 changes: 7 additions & 1 deletion lib/fizzbuzz.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ class SuperFizzBuzz

def run(input)

#Implement your code here
output = ""

output << "Fizz" if input % 3 == 0
output << "Buzz" if input % 5 == 0
output = input if output.empty?

output
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty slick.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw Jay use a similar method a few months back for running a FizzBuzz server with Sinatra and I was impressed with his work


end

Expand Down
15 changes: 12 additions & 3 deletions spec/deaf_grandma_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@
end

it "says 'NOT SINCE 1964!' when we yell" do
#implement your test here
expect(script.speak("HELLO!")).to eq "NOT SINCE 1964!"
end

it "EXTRA CREDIT: How would you test yelling BYE?" do
#implement your test here
it "says 'SEE YOU LATER SONNY! when we say 3 consecutive 'BYE's" 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 "SEE YOU LATER SONNY!"
end

it "says 'NOT SINCE 1964! when we say 3 'BYE's nonconsecutively" do
script.speak("BYE")
script.speak("BYE")
script.speak("I guess I'll stay")
expect(script.speak("BYE")).to eq "NOT SINCE 1964!"
end
end
6 changes: 3 additions & 3 deletions spec/fizzbuzz_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(4)).to eq 4
end
end