Sha256: a8e9f383ed0aff74e0d12285a6a17307be111eda8c4aee1cf84f5b6f8d597bf2
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
require 'test_helper' module ActiveModel class Serializer class ArraySerializerTest < Minitest::Test def setup @comment = Comment.new @post = Post.new @serializer = ArraySerializer.new([@comment, @post], {some: :options}) end def test_respond_to_each assert_respond_to @serializer, :each end def test_each_object_should_be_serialized_with_appropriate_serializer serializers = @serializer.to_a assert_kind_of CommentSerializer, serializers.first assert_kind_of Comment, serializers.first.object assert_kind_of PostSerializer, serializers.last assert_kind_of Post, serializers.last.object assert_equal serializers.last.custom_options[:some], :options end def test_serializer_option_not_passed_to_each_serializer serializers = ArraySerializer.new([@post], {serializer: PostSerializer}).to_a refute serializers.first.custom_options.key?(:serializer) end def test_meta_and_meta_key_attr_readers meta_content = {meta: "the meta", meta_key: "the meta key"} @serializer = ArraySerializer.new([@comment, @post], meta_content) assert_equal @serializer.meta, "the meta" assert_equal @serializer.meta_key, "the meta key" end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
cm-active_model_serializers-0.10.0.rc1.1 | test/array_serializer_test.rb |
active_model_serializers-0.10.0.rc2 | test/array_serializer_test.rb |