Sha256: f24f66ee1cd5058b74a264b9a6a3a4de755fdc21ec852010f32a02746464d980

Contents?: true

Size: 877 Bytes

Versions: 2

Compression:

Stored size: 877 Bytes

Contents

require 'test_helper'

module ActiveModel
  class Serializer
    class AttributesTest < ActiveRecord::TestCase
      def setup
        @profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
        @profile_serializer = ProfileSerializer.new(@profile)
      end

      def test_attributes_definition
        assert_equal([:name, :description],
                     @profile_serializer.class._attributes)
      end

      def test_attributes_serialization_using_serializable_hash
        assert_equal({
          name: 'Name 1', description: 'Description 1'
        }, @profile_serializer.serializable_hash)
      end

      def test_attributes_serialization_using_as_json
        assert_equal({
          'profile' => { name: 'Name 1', description: 'Description 1' }
        }, @profile_serializer.as_json)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_model_serializers_rails_2.3-0.9.0.pre2 test/unit/active_model/serializer/attributes_test.rb
active_model_serializers_rails_2.3-0.9.0.pre1 test/unit/active_model/serializer/attributes_test.rb