spec/unit/serialization/integer_spec.rb in rest_model-0.2.1 vs spec/unit/serialization/integer_spec.rb in rest_model-0.2.3
- old
+ new
@@ -1,9 +1,17 @@
require 'spec_helper'
describe RestModel::Serialization::Integer do
+ it "adds leading zeros from options while desserializing" do
+ subject.class.desserialize('1200', padding_zeros: 12).should == "000000001200"
+ end
+
it "converts to integer" do
subject.class.serialize('1200').should == 1200
+ end
+
+ it "converts negative number to negative integer" do
+ subject.class.serialize('-1').should == -1
end
context "when an invalid value is serialized" do
it "raises an error" do
expect {subject.class.serialize("not an integer")}.to raise_error