spec/quantity_spec.rb in quantify-1.0.2 vs spec/quantity_spec.rb in quantify-1.0.3
- old
+ new
@@ -244,7 +244,22 @@
it "should cancel by base units of original compound unit if necessary" do
quantity = Quantity.new(20, Unit.psi).to(Unit.inches_of_mercury)
quantity.unit.base_units.size.should == 1
quantity.to_s.should == "40.720412743579 inHg"
end
+
+ it "should rationalize units and return new quantity" do
+ quantity = 12.yards*36.feet
+ quantity.to_s.should eql "432.0 yd ft"
+ new_quantity=quantity.rationalize_units
+ quantity.to_s.should eql "432.0 yd ft"
+ new_quantity.to_s.should eql "144.0 yd^2"
+ end
+
+ it "should rationalize units and modify value in place" do
+ quantity = 12.yards*36.feet
+ quantity.to_s.should eql "432.0 yd ft"
+ quantity.rationalize_units!
+ quantity.to_s.should eql "144.0 yd^2"
+ end
end