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

Implemented the Rspec drills problem set #86

Open
wants to merge 5 commits 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
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.0.0'

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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion lib/deaf_grandma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ def run!


def speak(input)
said_bye = input.start_with?("BYE")

#Implement your code here <<<<<<<<<
@bye_counter += 1 if said_bye

if said_bye && @bye_counter > 2
"BYE!"
elsif input == input.upcase
"NOT SINCE 1964!"
else
"SPEAK UP SONNY!"
end
end

private
Expand Down
12 changes: 9 additions & 3 deletions lib/fizzbuzz.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
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.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 "NOT SINCE 1964!"
expect(script.speak("BYE!")).to eq "NOT SINCE 1964!"
expect(script.speak("BYE!")).to eq "BYE!"
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(7)).to eq 7
end
end