Skip to content

Instantly share code, notes, and snippets.

@ivanacostarubio
Forked from CoryFoy/gist:4383355
Last active December 10, 2015 04:58
Show Gist options
  • Save ivanacostarubio/4384241 to your computer and use it in GitHub Desktop.
Save ivanacostarubio/4384241 to your computer and use it in GitHub Desktop.
require 'rr'
class CrazyMath
def self.fib(n)
if n < 3
1
else
CrazyMath.fib(n - 1) + CrazyMath.fib(n - 2)
end
end
end
Spec::Runner.configure do |config|
config.mock_with :rr
end
describe "Fib" do
it "fib 1" do
CrazyMath.fib(1).should == 1
end
it "fib 2" do
CrazyMath.fib(2).should == 1
end
it "fib 6" do
mock.proxy(CrazyMath).fib(1).times(any_times)
mock.proxy(CrazyMath).fib(2).times(any_times)
mock.proxy(CrazyMath).fib(3).times(any_times)
mock.proxy(CrazyMath).fib(4).times(any_times)
mock.proxy(CrazyMath).fib(5).times(any_times)
mock.proxy(CrazyMath).fib(6)
CrazyMath.fib(6).should == 8
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment