-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfizz_buzz_specs.rb
More file actions
53 lines (45 loc) · 1.05 KB
/
fizz_buzz_specs.rb
File metadata and controls
53 lines (45 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require_relative 'fizz_buzz.rb'
describe FizzBuzz do
before(:each) do
@fizzbuzz = FizzBuzz.new
end
it 'Play FizzBuzz!' do
@fizzbuzz.next.should == 1
@fizzbuzz.next.should == 2
end
it 'should fizz on numbers that are evenly divided by 3' do
count(2)
@fizzbuzz.next.should == 'fizz'
count(2)
@fizzbuzz.next.should == 'fizz'
end
it 'should fizz if it has a 3 in the number' do
count(12)
@fizzbuzz.next.should == 'fizz'
count(9)
@fizzbuzz.next.should == 'fizz'
end
it 'should buzz if it divides evenly by 5' do
count(4)
@fizzbuzz.next.should == 'buzz'
count(4)
@fizzbuzz.next.should == 'buzz'
end
it 'should buzz if the number has 5 in it' do
count 49
@fizzbuzz.next.should == 'buzz'
end
it 'should fizzbuzz if the number is a product of both 3 and 5' do
count 14
@fizzbuzz.next.should == 'fizzbuzz'
end
it 'should buzz in the fifties' do
count 51
@fizzbuzz.next.should == 'buzz'
end
def count(i)
i.times do
@fizzbuzz.next
end
end
end