Advertisement
ZaBlanc

Kata 8/24 Fizz Buzz w/ RSpec Tests

Aug 24th, 2011
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.87 KB | None | 0 0
  1. require "rspec"
  2. require "fizz_buzz"
  3.  
  4. describe FizzBuzz do
  5.   before :each do
  6.     @fb = FizzBuzz.new
  7.   end
  8.  
  9.   it 'should specify FizzBuzz for numbers divisible by 3 and 5' do
  10.     @fb.fizz(-15).should == "FizzBuzz"
  11.     @fb.fizz(0).should == "FizzBuzz"
  12.     @fb.fizz(15).should == "FizzBuzz"
  13.     @fb.fizz(30).should == "FizzBuzz"
  14.   end
  15.  
  16.   it 'should specify Fizz for numbers divisible by 3' do
  17.     @fb.fizz(-3).should == "Fizz"
  18.     @fb.fizz(3).should == "Fizz"
  19.     @fb.fizz(6).should == "Fizz"
  20.   end
  21.  
  22.   it 'should display Buzz for numbers divisible by 5' do
  23.     @fb.fizz(-5).should == "Buzz"
  24.     @fb.fizz(5).should == "Buzz"
  25.   end
  26.  
  27.   it 'should display the number for numbers not divisible by 3 or 5' do
  28.     @fb.fizz(-1).should == "-1"
  29.     @fb.fizz(1).should == "1"
  30.     @fb.fizz(2).should == "2"
  31.     @fb.fizz(4).should == "4"
  32.     @fb.fizz(7).should == "7"
  33.   end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement