Skip to content

Instantly share code, notes, and snippets.

@andyh
Created October 18, 2011 22:08
Show Gist options
  • Save andyh/1296878 to your computer and use it in GitHub Desktop.
Save andyh/1296878 to your computer and use it in GitHub Desktop.
Calculate Vat
Gem::Specification.new do |s|
s.name = 'calculate_vat'
s.version = '0.1.1'
s.platform = Gem::Platform::RUBY
s.author = 'Andy Henson'
s.email = 'andy@elaptics.co.uk'
s.summary = 'Calculate VAT stuff!'
s.description = 'Calculates UK VAT type stuff'
s.files = ['calculate_vat.rb']
s.test_file = 'calculate_vat_spec.rb'
s.require_path = '.'
s.add_development_dependency('rspec', ["~> 2.0"])
end
module CalculateVat
VAT_RATE = 20.0
def gross(value)
total = value + value * (VAT_RATE/100)
total.round(2)
end
end
require File.expand_path('calculate_vat')
class ObjectWithCalculateVat
end
describe CalculateVat do
let(:object) do
object = ObjectWithCalculateVat.new
object.extend(CalculateVat)
object
end
context "calculating total price given a net amount" do
it "should return total of net amount plus vat amount" do
object.gross(10).should == 12.00
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment