Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All pass #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
source 'https://rubygems.org'
ruby '2.0.0'

gem 'rspec', '~> 3.0.0.beta2'
7 changes: 5 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.2.5)
diff-lcs (1.3)
rspec (3.0.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
Expand All @@ -16,7 +16,10 @@ GEM
rspec-support (3.0.4)

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
rspec (~> 3.0.0.beta2)

BUNDLED WITH
1.14.4
22 changes: 12 additions & 10 deletions lib/deaf_grandma.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#This script is different than FizzBuzz. It should accept user input from the terminal if done correctly. Run it to see what it does then complete the speak method so that it returns & prints the correct thing.

#CAREFUL! This script will not exit. Do you know why? You may have to close it with `Ctrl-C` (Mac) if you do not insert an `exit` into your speak method.

# Solution to rspec file
class DeafGrandma

def initialize
Expand All @@ -19,9 +16,17 @@ def run!


def speak(input)
"SPEAK UP SONNY!"
end

#Implement your code here <<<<<<<<<

def YELL(input)
@bye_counter += 1 if input.casecmp('bye').zero?
if @bye_counter <= 2
"NOT SINCE 1964!"
else
@bye_counter = 0
"SEE YOU LATER SONNY!"
end
Copy link

Choose a reason for hiding this comment

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

Try to make it so that whether the user's speech counts as speaking or yelling depends on the nature of the input, not the method you're calling.

end

private
Expand All @@ -35,7 +40,4 @@ def get_user_input
gets.chomp
end

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!
end
17 changes: 7 additions & 10 deletions lib/fizzbuzz.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# class to pass fizzbuzz spec
class SuperFizzBuzz

def run(input)

#Implement your code here

output = ''
output = input unless (input % 3).zero? || (input % 5).zero?
output << 'Fizz' if (input % 3).zero?
output << 'Buzz' if (input % 5).zero?
output
end

end

#You don't necessarily need to execute this script to complete this challenge, but how would you "run" this method (pun intended) so that it printed a value to the terminal?
#
#HINT: it's an instance method.
end
6 changes: 4 additions & 2 deletions spec/deaf_grandma_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
end

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

it "EXTRA CREDIT: How would you test yelling BYE?" do
#implement your test here
expect(script.YELL("Bye")).to eq "NOT SINCE 1964!"
expect(script.YELL("Bye")).to eq "NOT SINCE 1964!"
expect(script.YELL("Bye")).to eq "SEE YOU LATER SONNY!"
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