Skip to content

Instantly share code, notes, and snippets.

@lkrych
Created October 11, 2016 18:29
Show Gist options
  • Save lkrych/3b3c006e2910b6472220bb0259947d54 to your computer and use it in GitHub Desktop.
Save lkrych/3b3c006e2910b6472220bb0259947d54 to your computer and use it in GitHub Desktop.
RSpec for factorial function
require_relative '../factorial.rb'
describe "Test the factorial function" do
it 'returns the right answer for 5' do
expect(factorial(5)).to eq(120)
end
it 'returns the right answer for 10' do
expect(factorial(10)).to eq(3628800)
end
it 'returns an error message for -5' do
expect(factorial(-5)).to eq(nil)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment