Sha256: 5536ec4464877d7bcde80aa78aededa73b0a913ec53d2c15099b4daf21c258b3

Contents?: true

Size: 569 Bytes

Versions: 15

Compression:

Stored size: 569 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"
    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

15 entries across 15 versions & 1 rubygems

Version Path
roar-0.11.19 test/coercion_feature_test.rb
roar-0.11.18 test/coercion_feature_test.rb
roar-0.11.17 test/coercion_feature_test.rb
roar-0.11.16 test/coercion_feature_test.rb
roar-0.11.15 test/coercion_feature_test.rb
roar-0.11.14 test/coercion_feature_test.rb
roar-0.11.13 test/coercion_feature_test.rb
roar-0.11.12 test/coercion_feature_test.rb
roar-0.11.11 test/coercion_feature_test.rb
roar-0.11.10 test/coercion_feature_test.rb
roar-0.11.9 test/coercion_feature_test.rb
roar-0.11.8 test/coercion_feature_test.rb
roar-0.11.7 test/coercion_feature_test.rb
roar-0.11.6 test/coercion_feature_test.rb
roar-0.11.5 test/coercion_feature_test.rb