Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created August 4, 2011 08:56
Show Gist options
  • Save ukstudio/1124762 to your computer and use it in GitHub Desktop.
Save ukstudio/1124762 to your computer and use it in GitHub Desktop.
class FizzBuzz
def self.say(num)
str = [[:Fizz][num%3], [:Buzz][num%5]].join('')
str.empty? ? num : str
end
end
describe FizzBuzz do
subject { described_class.say(num) }
context 'with 1' do
let(:num) { 1 }
it { should eq 1 }
end
context 'with 3' do
let(:num) { 3 }
it { should eq 'Fizz' }
end
context 'with 5' do
let(:num) { 5 }
it { should eq 'Buzz' }
end
context 'with 15' do
let(:num) { 15 }
it { should eq 'FizzBuzz' }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment