require 'test/unit' require 'test/framework' require 'units' class TC_unit_ambiguity < Test::Unit::TestCase understands UnitsTest def test_unit_ambiguity Units.create :volume do |m| m.system :english do |s| s.unit :name => :ounce, :abbrev => :oz end end volume_ounce = Units.volume.english.ounce Units.create :mass do |m| m.system :english do |s| s.unit :name => :ounce, :abbrev => :oz end end mass_ounce = Units.mass.english.ounce assert(volume_ounce.equals.unit == {volume_ounce => 1}) assert(mass_ounce.equals.unit == {mass_ounce => 1}) Units.create :volume do |m| m.system :english do |s| s.unit :name => :cup, :abbrev => :c, :equals => 16.ounces end end cup = Units.volume.english.cup assert(cup.equals.unit == {volume_ounce => 1}) Units.create :mass do |m| m.system :english do |s| s.unit :name => :pound, :abbrev => :lb, :equals => 16.ounces end end pound = Units.mass.english.pound assert(pound.equals.unit == {mass_ounce => 1}) end end