require 'test/unit' require 'test/framework' require 'eymiha/units' class TC_unit_create < Test::Unit::TestCase include UnitsTest def test_unit_create Units.create :length do |m| m.system 'english' do |s| s.unit :name => 'inch' s.unit :name => 'foot' end end inch = Units.length.english.inch foot = Units.length.english.foot assert(inch.kind_of?(UnitsUnit)) assert(foot.kind_of?(UnitsUnit)) assert(inch.name == 'inch') assert(foot.name == 'foot') assert(inch.units_system == Units.length.english) assert(foot.units_system == Units.length.english) assert(inch.units_system.units_measure == Units.length) assert(foot.units_system.units_measure == Units.length) assert(Units.length.english.keys.index('inch') != nil) assert(Units.length.english.keys.index('foot') != nil) assert(Units.length.english.keys.index('foo') == nil) end end