Sha256: 00e4ca23a58a76252793c08ad5c17fb719ac6bb24d0eb5c6f5202acfdf4d7bf5

Contents?: true

Size: 579 Bytes

Versions: 7

Compression:

Stored size: 579 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

7 entries across 7 versions & 1 rubygems

Version Path
roar-0.11.4 test/coercion_feature_test.rb
roar-0.11.3 test/coercion_feature_test.rb
roar-0.11.2 test/coercion_feature_test.rb
roar-0.11.1 test/coercion_feature_test.rb
roar-0.11.0 test/coercion_feature_test.rb
roar-0.10.2 test/coercion_feature_test.rb
roar-0.10.1 test/coercion_feature_test.rb