Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Ruby on Rails Interview Question (1)
require 'rspec'
def format_money(amount)
'-1' #TODO
end
describe "format_money" do
context "when the amount is a simple fraction" do
subject{ 0.4 }
specify{ format_money(subject).should == "$0.40" }
end
context "when the amount is a negative fraction" do
subject{ -0.4 }
specify{ format_money(subject).should == "-$0.40" }
end
context "when the amount is a tricky fraction" do
subject{ 0.9 / 100 }
specify{ format_money(subject).should == "$0.009" }
end
context "when the amount is a tricky negative fraction" do
subject{ 0.9 / 100 * -1 }
specify{ format_money(subject).should == "-$0.009" }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.