add specs for weight calculators using lbs

This commit is contained in:
Andy Brett
2020-09-24 07:03:57 -07:00
parent 9ef706a201
commit 84eb8e964d

View File

@@ -62,6 +62,8 @@ describe Calculator::Weight do
subject.set_preference(:per_unit, 5)
subject.set_preference(:unit_from_list, "kg")
expect(subject.compute(object_with_order)).to eq(250) # (10 * 1 + 20 * 2) * 5
subject.set_preference(:unit_from_list, "lb")
expect(subject.compute(object_with_order)).to eq(551.15) # (10 * 1 + 20 * 2) * 5 * 2.2
end
context "when line item final_weight_volume is set" do
@@ -214,6 +216,8 @@ describe Calculator::Weight do
subject.set_preference(:per_unit, 5)
subject.set_preference(:unit_from_list, "kg")
expect(subject.calculable.errors.count).to eq(0)
subject.set_preference(:unit_from_list, "lb")
expect(subject.calculable.errors.count).to eq(0)
end
it "does not allow a preferred_unit of anything but 'kg' or 'lb'" do