spec/lib/aixm/w_spec.rb in aixm-0.3.7 vs spec/lib/aixm/w_spec.rb in aixm-0.3.8
- old
+ new
@@ -5,146 +5,146 @@
AIXM::Factory.w
end
describe :wgt= do
it "fails on invalid values" do
- [:foobar, -1].wont_be_written_to subject, :wgt
+ _([:foobar, -1]).wont_be_written_to subject, :wgt
end
it "converts Numeric to Float" do
- subject.tap { |s| s.wgt = 5 }.wgt.must_equal 5.0
+ _(subject.tap { |s| s.wgt = 5 }.wgt).must_equal 5.0
end
end
describe :unit= do
it "fails on invalid values" do
- [:foobar, 123].wont_be_written_to subject, :unit
+ _([:foobar, 123]).wont_be_written_to subject, :unit
end
it "symbolizes and downcases values" do
- subject.tap { |s| s.unit = "KG" }.unit.must_equal :kg
+ _(subject.tap { |s| s.unit = "KG" }.unit).must_equal :kg
end
end
describe :to_kg do
it "leaves kilograms untouched" do
subject = AIXM.w(2, :kg)
- subject.to_kg.must_be_same_as subject
+ _(subject.to_kg).must_be_same_as subject
end
it "converts metric tonnes to kilograms" do
- AIXM.w(0.5, :t).to_kg.must_equal AIXM.w(500, :kg)
+ _(AIXM.w(0.5, :t).to_kg).must_equal AIXM.w(500, :kg)
end
it "converts pound to kilograms" do
- AIXM.w(200, :lb).to_kg.must_equal AIXM.w(90.718474, :kg)
+ _(AIXM.w(200, :lb).to_kg).must_equal AIXM.w(90.718474, :kg)
end
it "converts US tons to kilograms" do
- AIXM.w(0.5, :ton).to_kg.must_equal AIXM.w(453.59237, :kg)
+ _(AIXM.w(0.5, :ton).to_kg).must_equal AIXM.w(453.59237, :kg)
end
end
describe :to_t do
it "leaves metric tonnes untouched" do
subject = AIXM.w(2, :t)
- subject.to_t.must_be_same_as subject
+ _(subject.to_t).must_be_same_as subject
end
it "converts kilograms to metric tonnes" do
- AIXM.w(10_000, :kg).to_t.must_equal AIXM.w(10, :t)
+ _(AIXM.w(10_000, :kg).to_t).must_equal AIXM.w(10, :t)
end
it "converts pound to metric tonnes" do
- AIXM.w(1000, :lb).to_t.must_equal AIXM.w(0.45359237, :t)
+ _(AIXM.w(1000, :lb).to_t).must_equal AIXM.w(0.45359237, :t)
end
it "converts US tons to metric tonnes" do
- AIXM.w(1, :ton).to_t.must_equal AIXM.w(0.90718474, :t)
+ _(AIXM.w(1, :ton).to_t).must_equal AIXM.w(0.90718474, :t)
end
end
describe :to_lb do
it "leaves pound untouched" do
subject = AIXM.w(2, :lb)
- subject.to_lb.must_be_same_as subject
+ _(subject.to_lb).must_be_same_as subject
end
it "converts kilograms to pound" do
- AIXM.w(50, :kg).to_lb.must_equal AIXM.w(110.2311311, :lb)
+ _(AIXM.w(50, :kg).to_lb).must_equal AIXM.w(110.2311311, :lb)
end
it "converts metric tonnes to pound" do
- AIXM.w(0.5, :t).to_lb.must_equal AIXM.w(1102.311311, :lb)
+ _(AIXM.w(0.5, :t).to_lb).must_equal AIXM.w(1102.311311, :lb)
end
it "converts US tons to pound" do
- AIXM.w(0.5, :ton).to_lb.must_equal AIXM.w(1000.00000007, :lb)
+ _(AIXM.w(0.5, :ton).to_lb).must_equal AIXM.w(1000.00000007, :lb)
end
end
describe :to_ton do
it "leaves US tons untouched" do
subject = AIXM.w(2, :ton)
- subject.to_ton.must_be_same_as subject
+ _(subject.to_ton).must_be_same_as subject
end
it "converts kilograms to US tons" do
- AIXM.w(1000, :kg).to_ton.must_equal AIXM.w(1.10231131, :ton)
+ _(AIXM.w(1000, :kg).to_ton).must_equal AIXM.w(1.10231131, :ton)
end
it "converts metrical tons to US tons" do
- AIXM.w(0.5, :t).to_ton.must_equal AIXM.w(0.55115566, :ton)
+ _(AIXM.w(0.5, :t).to_ton).must_equal AIXM.w(0.55115566, :ton)
end
it "converts pound to US tons" do
- AIXM.w(3000, :lb).to_ton.must_equal AIXM.w(1.5, :ton)
+ _(AIXM.w(3000, :lb).to_ton).must_equal AIXM.w(1.5, :ton)
end
end
describe :<=> do
it "recognizes objects with identical unit and weight as equal" do
a = AIXM.w(123, :kg)
b = AIXM.w(123.0, 'KG')
- a.must_equal b
+ _(a).must_equal b
end
it "recognizes objects with different units and converted weight as equal" do
a = AIXM.w(123, :kg)
b = AIXM.w(271.16858251, 'LB')
- a.must_equal b
+ _(a).must_equal b
end
it "recognizes objects with different units and identical weight as unequal" do
a = AIXM.w(123, :kg)
b = AIXM.w(123, :lb)
- a.wont_equal b
+ _(a).wont_equal b
end
it "recognizes objects of different class as unequal" do
a = AIXM.w(123, :kg)
b = :oggy
- a.wont_equal b
+ _(a).wont_equal b
end
end
describe :hash do
it "returns an integer" do
- subject.hash.must_be_instance_of Integer
+ _(subject.hash).must_be_instance_of Integer
end
it "allows for the use of instances as hash keys" do
dupe = subject.dup
- { subject => true }[dupe].must_equal true
+ _({ subject => true }[dupe]).must_equal true
end
end
describe :zero? do
it "returns true for zero weight" do
- subject.tap { |s| s.wgt = 0 }.must_be :zero?
+ _(subject.tap { |s| s.wgt = 0 }).must_be :zero?
end
it "returns false for non-zero weight" do
- subject.tap { |s| s.wgt = 1 }.wont_be :zero?
+ _(subject.tap { |s| s.wgt = 1 }).wont_be :zero?
end
end
end