Getting started: attributes.

Super super basic collection of attributes. Nothing fancy.
This commit is contained in:
Steve Klabnik
2014-07-09 16:16:39 -04:00
parent a45b5eeda3
commit 729a823868
9 changed files with 68 additions and 13 deletions

18
test/attributes_test.rb Normal file
View File

@@ -0,0 +1,18 @@
require 'test_helper'
module ActiveModel
class Serializer
class AttributesTest < Minitest::Test
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
end
end
end

12
test/fixtures/poro.rb vendored Normal file
View File

@@ -0,0 +1,12 @@
class Model
def initialize(hash={})
@attributes = hash
end
end
class Profile < Model
end
class ProfileSerializer < ActiveModel::Serializer
attributes :name, :description
end

View File

@@ -1,8 +1,9 @@
require "bundler/setup"
require "active_model_serializers"
require "active_support/json"
require 'rails'
require "active_support/json"
require 'minitest/autorun'
require "active_model_serializers"
require 'fixtures/poro'