Skip to content

Instantly share code, notes, and snippets.

@gorsuch
Created January 7, 2011 13:33
Show Gist options
  • Save gorsuch/769452 to your computer and use it in GitHub Desktop.
Save gorsuch/769452 to your computer and use it in GitHub Desktop.
describe FizzBuzz, "#calculate" do
it "returns 'Fizz' for all multiples of 3"
it "returns 'Buzz' for all multiples of 5"
it "returns 'FizzBuzz' for all multiples of 3 and 5"
it "returns the passed number if not a multiple of 3 or 5"
end
class FizzBuzz
def calculate(n)
if n % 3 == 0 and n % 5 == 0
"FizzBuzz"
elsif n % 3 == 0
"Fizz"
elsif n % 5 == 0
"Buzz"
else
n
end
end
end
describe FizzBuzz, "#calculate" do
let(:fb) { FizzBuzz.new }
it "returns 'Fizz' for all multiples of 3" do
fb.calculate(3).should == "Fizz"
end
it "returns 'Buzz' for all multiples of 5" do
fb.calculate(5).should == "Buzz"
end
it "returns 'FizzBuzz' for all multiples of 3 and 5" do
fb.calculate(15).should == "FizzBuzz"
end
it "returns the passed number if not a multiple of 3 or 5" do
fb.calculate(77).should == 77
end
end
Pending:
FizzBuzz#calculate returns 'Fizz' for all multiples of 3
# Not Yet Implemented
# ./fizzbuzz_spec.rb:16
FizzBuzz#calculate returns 'Buzz' for all multiples of 5
# Not Yet Implemented
# ./fizzbuzz_spec.rb:17
FizzBuzz#calculate returns 'FizzBuzz' for all multiples of 3 and 5
# Not Yet Implemented
# ./fizzbuzz_spec.rb:18
FizzBuzz#calculate returns the passed number if not a multiple of 3 or 5
# Not Yet Implemented
# ./fizzbuzz_spec.rb:19
Finished in 0.00061 seconds
4 examples, 0 failures, 4 pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment