Skip to content

Instantly share code, notes, and snippets.

@djgraham
Created January 29, 2011 23:01
Show Gist options
  • Select an option

  • Save djgraham/802296 to your computer and use it in GitHub Desktop.

Select an option

Save djgraham/802296 to your computer and use it in GitHub Desktop.
square software engineer spec example
class Payment
attr_accessor :amount
def initialize (x)
self.amount = amount
end
def fee_amount
(((2.9 * (self.amount * 100)) / 100) + 15).round.to_f/100
end
end
# actual rspec bit below
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment