Sha256: ee97bfdb7f0ff4fadd7abf13d6a307e1d39d777513137c753b2d898e4adc6f13
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
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_serializer assert_equal @serializer, @adapter.serializer end def test_adapter_class_for_known_adapter klass = ActiveModel::Serializer::Adapter.adapter_class(:json_api) assert_equal ActiveModel::Serializer::Adapter::JsonApi, klass end def test_adapter_class_for_unknown_adapter klass = ActiveModel::Serializer::Adapter.adapter_class(:json_simple) assert_nil klass end def test_create_adapter adapter = ActiveModel::Serializer::Adapter.create(@serializer) assert_equal ActiveModel::Serializer::Adapter::FlattenJson, adapter.class end def test_create_adapter_with_override adapter = ActiveModel::Serializer::Adapter.create(@serializer, { adapter: :json_api }) assert_equal ActiveModel::Serializer::Adapter::JsonApi, adapter.class end def test_inflected_adapter_class_for_known_adapter ActiveSupport::Inflector.inflections(:en) { |inflect| inflect.acronym 'API' } klass = ActiveModel::Serializer::Adapter.adapter_class(:json_api) ActiveSupport::Inflector.inflections.acronyms.clear assert_equal ActiveModel::Serializer::Adapter::JsonApi, klass end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cheap_ams-0.10.8 | test/adapter_test.rb |
cheap_ams-0.10.7 | test/adapter_test.rb |
cheap_ams-0.10.6 | test/adapter_test.rb |