class MassTest
Public Instance Methods
setup()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 8 def setup @mass = Mass.new(5, :pounds) end
test_comparison_with_numeric()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 55 def test_comparison_with_numeric assert 2.pounds > 1 assert 2.pounds == 2 assert 2.pounds <= 2 assert 2.pounds < 3 end
test_convert_grams_to_ounces()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 50 def test_convert_grams_to_ounces assert 1.ounces.eql?((28.349523125).grams.to_ounces) assert 1.ounces.eql?((28.349523125).grams.in_ounces) end
test_convert_milligrams_to_short_tons()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 46 def test_convert_milligrams_to_short_tons assert Mass.new(1, :short_tons).eql?(Mass.new(907_184_740, :milligrams).to_short_tons) end
test_convert_pounds_to_short_tons()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 38 def test_convert_pounds_to_short_tons assert Mass.new(2, :short_tons).eql?(4000.pounds.to_short_tons) end
test_convert_short_tons_to_milligrams()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 42 def test_convert_short_tons_to_milligrams assert Mass.new(907_184_740, :milligrams).eql?(Mass.new(1, :short_tons).to_milligrams) end
test_convert_short_tons_to_pounds()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 34 def test_convert_short_tons_to_pounds assert 4000.pounds.eql?(Mass.new(2, :short_tons).to_pounds) end
test_equalities()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 24 def test_equalities assert_equal 1.pounds, (1.0).pounds # == based on value assert_equal 4000.pounds, Mass.new(2, :short_tons) # eql? based on value and unit assert !4000.pounds.eql?(Mass.new(2, :short_tons)) # equal? based on object identity assert !2.pounds.equal?(2.pounds) end
test_initialize_from_numeric()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 20 def test_initialize_from_numeric assert_equal "5 pounds", 5.pounds.to_s end
test_inspect()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 12 def test_inspect assert_equal "#<Quantified::Mass: 5 pounds>", @mass.inspect end
test_method_missing_minus()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 70 def test_method_missing_minus assert_equal 2.pounds, 5.pounds - 3.pounds end
test_method_missing_to_f()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 66 def test_method_missing_to_f assert_equal 2.4, (2.4).pounds.to_f end
test_method_missing_to_i()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 62 def test_method_missing_to_i assert_equal 2, (2.4).pounds.to_i end
test_numeric_methods_not_added_for_some_units()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 74 def test_numeric_methods_not_added_for_some_units assert_raises NoMethodError do 2.short_tons end assert_raises NoMethodError do 2.milligrams end end
test_systems()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 83 def test_systems assert_equal [:metric, :imperial], Mass.systems assert_equal [:grams, :milligrams, :kilograms], Mass.units(:metric) assert_equal [:ounces, :pounds, :stones, :short_tons], Mass.units(:imperial) end
test_to_s()
click to toggle source
# File lib/vendor/quantified/test/mass_test.rb, line 16 def test_to_s assert_equal "5 pounds", @mass.to_s end