Sha256: 469b4864e546187e28d0c6b5b5dec59bb9375116bdeb2c332a901d280cfe9ece

Contents?: true

Size: 592 Bytes

Versions: 3

Compression:

Stored size: 592 Bytes

Contents

require 'spec_helper'

describe RestModel::Serialization::DateTime do
  it "converts to date time" do
    subject.class.serialize('2011-07-01T10:20:30').should == DateTime.new(2011, 07, 01, 10, 20, 30)
  end

  it "desserializes to date time respecting the provided format" do
    subject.class.desserialize(DateTime.new(2012, 12, 31, 12, 0, 0), format: "%a %b %d %H:%M:%S %Y").should == "Mon Dec 31 12:00:00 2012"
  end

  context "when an invalid value is serialized" do
    it "raises an error" do
      expect {subject.class.serialize("not a date time")}.to raise_error
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rest_model-0.3.1 spec/unit/serialization/date_time_spec.rb
rest_model-0.3.0 spec/unit/serialization/date_time_spec.rb
rest_model-0.2.3 spec/unit/serialization/date_time_spec.rb