Skip to content

Instantly share code, notes, and snippets.

@DavidBechtel
Created January 23, 2013 16:51
Show Gist options
  • Save DavidBechtel/4609710 to your computer and use it in GitHub Desktop.
Save DavidBechtel/4609710 to your computer and use it in GitHub Desktop.
fizzbuzz rspec test file
# fizz buzz generator spec
require './fizzbuzz_generator'
describe FizzBuzzGenerator, "#new" do
context 'given 15 as an input'
it "returns fizzbuzz for numbers 1 through 15 in an array" do
fizzbuzz = FizzBuzzGenerator.new(15)
fizzbuzz.should eq(["1 ","2 ","3 fizz ","4 ","5 buzz ","6 fizz ","7 ","8 ","9 fizz ","10 buzz ","11 ","12 fizz ","13 ","14 ","15 fizzbuzz "])
end
context 'given 0 as input'
it "returns 'not supported message' if 0 supplied" do
fizzbuzz = FizzBuzzGenerator.new(0)
fizzbuzz.should eq(["Zero, negative numbers, strings that describe a number, and nil not supported"])
end
context 'given negative input'
it "returns 'not supported message' if 0 supplied" do
fizzbuzz = FizzBuzzGenerator.new(-5)
fizzbuzz.should eq(["Zero, negative numbers, strings that describe a number, and nil not supported"])
end
context 'given nil input'
it "returns 'not supported message' if nothing supplied" do
fizzbuzz = FizzBuzzGenerator.new()
fizzbuzz.should eq(["Zero, negative numbers, strings that describe a number, and nil not supported"])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment