* Rename NullAdapter to SimpleAdapter

* Introduce abstract Adapter class
* Organaze test structure to match convemtions
This commit is contained in:
Tema Bolshakov
2014-08-27 08:17:36 +04:00
parent 0c13956311
commit f00fe5595d
7 changed files with 52 additions and 10 deletions

View File

@@ -3,15 +3,15 @@ require 'test_helper'
module ActiveModel
class Serializer
class Adapter
class NullAdapterTest < Minitest::Test
class SimpleAdapterTest < Minitest::Test
def setup
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
@profile_serializer = ProfileSerializer.new(@profile)
@adapter = NullAdapter.new(@profile_serializer)
@adapter = SimpleAdapter.new(@profile_serializer)
end
def test_null_adapter
def test_simple_adapter
assert_equal('{"name":"Name 1","description":"Description 1"}',
@adapter.to_json)

25
test/adapter_test.rb Normal file
View File

@@ -0,0 +1,25 @@
require 'test_helper'
module ActiveModel
class Serializer
class AdapterTest < Minitest::Test
def setup
profile = Profile.new
serializer = ProfileSerializer.new(profile)
@adapter = ActiveModel::Serializer::Adapter.new(serializer)
end
def test_serializable_hash_is_abstract_method
assert_raises(NotImplementedError) do
@adapter.serializable_hash(only: [:name])
end
end
def test_serializable_hash_is_abstract_method
assert_raises(NotImplementedError) do
@adapter.to_json(only: [:name])
end
end
end
end
end