Sha256: 57578f8c532228f7a67d6847ebc219f8758bf138b7be0331ae55fc60b9b1a977

Contents?: true

Size: 603 Bytes

Versions: 10

Compression:

Stored size: 603 Bytes

Contents

require 'test_helper'
require 'roar/representer/feature/coercion'

class CoercionFeatureTest < MiniTest::Spec
  describe "Coercion" do
    class ImmigrantSong
      include Roar::Representer::JSON
      include Roar::Representer::Feature::Coercion

      property :composed_at, :type => DateTime, :default => "May 12th, 2012"

      attr_accessor :composed_at
    end

    it "coerces into the provided type" do
      song = ImmigrantSong.new.from_json("{\"composed_at\":\"November 18th, 1983\"}")
      assert_equal DateTime.parse("Fri, 18 Nov 1983 00:00:00 +0000"), song.composed_at
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
roar-0.12.9 test/coercion_feature_test.rb
roar-0.12.8 test/coercion_feature_test.rb
roar-0.12.7 test/coercion_feature_test.rb
roar-0.12.6 test/coercion_feature_test.rb
roar-0.12.5 test/coercion_feature_test.rb
roar-0.12.4 test/coercion_feature_test.rb
roar-0.12.3 test/coercion_feature_test.rb
roar-0.12.2 test/coercion_feature_test.rb
roar-0.12.1 test/coercion_feature_test.rb
roar-0.12.0 test/coercion_feature_test.rb