Sha256: bf38eed2859740e513a9fe88411a31cdc51c92fc86634245c14a697bbb3b6d1d
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
require "lanes/spec_helper" describe Lanes::Numbers do Num = Lanes::Numbers def test_percnum assert Num::PercNum.new( '5%' ).is_percentage?, "is a percentage" assert Num::PercNum.new( '5% ' ).is_percentage?, "is a percentage" assert Num::PercNum.new( '5.3 % ' ).is_percentage?, "is a percentage" refute Num::PercNum.new( '$5.3 ' ).is_percentage?, "is not a percentage" # this is debatable, but we have to draw the line somewhere refute Num::PercNum.new( '%5.3 ' ).is_percentage?, "is a percentage" assert_equal '95.0', Num::PercNum.new( '5' ).debit_from(100).to_s assert_equal '95.0', Num::PercNum.new( '5%' ).debit_from(100).to_s assert_equal '105.0', Num::PercNum.new( '5%' ).credit_to(100).to_s assert_equal '95.0', Num::PercNum.new( '-5%').credit_to(100).to_s assert_equal '137.38449', Num::PercNum.new( '33.383%' ).credit_to(103).to_s assert_equal '68.61551', Num::PercNum.new( '33.383%' ).debit_from(103).to_s end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lanes-0.1.2 | spec/numbers_spec.rb |
lanes-0.1.0 | spec/numbers_spec.rb |
lanes-0.0.8 | spec/numbers_spec.rb |