main
1require "spec_helper"
2
3def fibonacci(n)
4end
5
6def fibonacci_enumerator
7end
8
9describe "fibonacci" do
10 it "should return the first n numbers in fibonacci" do
11 f = ->(x){ x < 2 ? x : f.call(x-1) + f.call(x-2) }
12 20.times do |n|
13 fibonacci(n).should == f.call(n)
14 end
15 end
16
17 it "can enumerate forever" do
18 results = fibonacci_enumerator.take(18)
19 f = ->(x){ x < 2 ? x : f.call(x-1) + f.call(x-2) }
20 18.times do |n|
21 results.should include(f.call(n))
22 end
23 end
24end
25