mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Use more meaningful model names for tests
This commit is contained in:
@@ -5,25 +5,25 @@ module ActiveModel
|
||||
class Serializer
|
||||
class AttributesTest < ActiveModel::TestCase
|
||||
def setup
|
||||
model = ::Model.new({ :attr1 => 'value1', :attr2 => 'value2', :attr3 => 'value3' })
|
||||
@model_serializer = ModelSerializer.new(model)
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
@profile_serializer = ProfileSerializer.new(@profile)
|
||||
end
|
||||
|
||||
def test_attributes_definition
|
||||
assert_equal(['attr1', 'attr2'],
|
||||
@model_serializer.class._attributes)
|
||||
assert_equal(['name', 'description'],
|
||||
@profile_serializer.class._attributes)
|
||||
end
|
||||
|
||||
def test_attributes_serialization_using_serializable_hash
|
||||
assert_equal({
|
||||
'attr1' => 'value1', 'attr2' => 'value2'
|
||||
}, @model_serializer.serializable_hash)
|
||||
'name' => 'Name 1', 'description' => 'Description 1'
|
||||
}, @profile_serializer.serializable_hash)
|
||||
end
|
||||
|
||||
def test_attributes_serialization_using_as_json
|
||||
assert_equal({
|
||||
'attr1' => 'value1', 'attr2' => 'value2'
|
||||
}, @model_serializer.as_json)
|
||||
'name' => 'Name 1', 'description' => 'Description 1'
|
||||
}, @profile_serializer.as_json)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user