Created
October 18, 2011 22:08
-
-
Save andyh/1296878 to your computer and use it in GitHub Desktop.
Calculate Vat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CalculateVat | |
VAT_RATE = 20.0 | |
def gross(value) | |
total = value + value * (VAT_RATE/100) | |
total.round(2) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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