Created
          August 4, 2011 08:56 
        
      - 
      
- 
        Save ukstudio/1124762 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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