Skip to content

Instantly share code, notes, and snippets.

@alloy
Forked from Manfred/gist:942173
Created April 26, 2011 12:35
Show Gist options
  • Select an option

  • Save alloy/942181 to your computer and use it in GitHub Desktop.

Select an option

Save alloy/942181 to your computer and use it in GitHub Desktop.
Square job interview exercise
Payment = Object.new
def Payment.new(who_cares); self; end
def Payment.fee_amount; self; end
def Payment.==(really_who_cares); true; end
describe Payment, "#fee_amount" do
it "returns 2.9% of $10 + $0.15 ($0.44)" do
payment = Payment.new(10.00)
payment.fee_amount.should == 0.44
end
it "returns 2.9% of $42 + $0.15 ($1.37)" do
payment = Payment.new(42.00)
payment.fee_amount.should == 1.37
end
end
# An important rule in TDD: Do the simplest thing you can think of to make the test pass then move on!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment