Sha256: 82cbfa38b18ddeb55f0f582317a4014379a7c4d2dce390736c2173b859cefe60
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
require "measured" require "minitest/autorun" require "mocha/setup" require "pry" ActiveSupport.test_order = :random require "support/fake_system" class ActiveSupport::TestCase protected def assert_close_bigdecimal exp, act, delta = BigDecimal('0.000001') n = (exp - act).abs msg = message(msg) { "Expected #{act.inspect} to be\nclose to #{exp.inspect} within #{delta} but was within #{n}" } assert delta >= n, msg end def assert_conversion(klass, from, to) from_amount, from_unit = from.split(" ") to_amount, to_unit = to.split(" ") to_unit = klass.unit_system.unit_for!(to_unit) assert_close_bigdecimal BigDecimal(to_amount), klass.new(from_amount, from_unit).convert_to(to_unit).value end def assert_exact_conversion(klass, from, to) from_amount, from_unit = from.split(" ") to_amount, to_unit = to.split(" ") to_unit = klass.unit_system.unit_for!(to_unit) assert_equal BigDecimal(to_amount), klass.new(from_amount, from_unit).convert_to(to_unit).value end def assert_raises_with_message(exception, expected_message) error = assert_raise(exception) { yield } assert_equal expected_message, error.message, "Exception #{exception} raised but messages are not equal" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
measured-2.0.0.pre3 | test/test_helper.rb |
measured-2.0.0.pre2 | test/test_helper.rb |