class LengthTest
Public Instance Methods
setup()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 8 def setup @length = Length.new(5, :feet) end
test_comparison_with_numeric()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 56 def test_comparison_with_numeric assert 2.feet > 1 assert 2.feet == 2 assert 2.feet <= 2 assert 2.feet < 3 end
test_convert_feet_to_yards()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 38 def test_convert_feet_to_yards assert Length.new(2, :yards).eql?(6.feet.to_yards) end
test_convert_metres_to_inches()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 50 def test_convert_metres_to_inches assert_equal 1.inches, (0.0254).metres.to_inches assert 1.inches.eql?((0.0254).metres.to_inches) assert 1.inches.eql?((0.0254).metres.in_inches) end
test_convert_millimetres_to_yards()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 46 def test_convert_millimetres_to_yards assert Length.new(1, :yards).eql?(Length.new(914.4, :millimetres).to_yards) end
test_convert_yards_to_feet()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 34 def test_convert_yards_to_feet assert 6.feet.eql?(Length.new(2, :yards).to_feet) end
test_convert_yards_to_millimetres()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 42 def test_convert_yards_to_millimetres assert Length.new(914.4, :millimetres).eql?(Length.new(1, :yards).to_millimetres) end
test_equalities()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 24 def test_equalities assert_equal 1.feet, (1.0).feet # == based on value assert_equal 6.feet, Length.new(2, :yards) # eql? based on value and unit assert !6.feet.eql?(Length.new(2, :yards)) # equal? based on object identity assert !2.feet.equal?(2.feet) end
test_initialize_from_numeric()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 20 def test_initialize_from_numeric assert_equal "5 feet", 5.feet.to_s end
test_inspect()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 12 def test_inspect assert_equal "#<Quantified::Length: 5 feet>", @length.inspect end
test_method_missing_minus()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 71 def test_method_missing_minus assert_equal 2.feet, 5.feet - 3.feet end
test_method_missing_to_f()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 67 def test_method_missing_to_f assert_equal 2.4, (2.4).feet.to_f end
test_method_missing_to_i()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 63 def test_method_missing_to_i assert_equal 2, (2.4).feet.to_i end
test_numeric_methods_not_added_for_some_units()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 75 def test_numeric_methods_not_added_for_some_units assert_raises NoMethodError do 2.yards end assert_raises NoMethodError do 2.millimetres end end
test_systems()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 84 def test_systems assert_equal [:metric, :imperial], Length.systems assert_equal [:metres, :centimetres, :millimetres, :kilometres], Length.units(:metric) assert_equal [:inches, :feet, :yards, :miles], Length.units(:imperial) assert_equal :metric, 2.centimetres.system assert_equal :imperial, 2.feet.system end
test_to_s()
click to toggle source
# File lib/vendor/quantified/test/length_test.rb, line 16 def test_to_s assert_equal "5 feet", @length.to_s end