Sha256: ce50602ee768141e2cd6b5e2799320ebc0439b643dfdbd3e82f4847ab3f83196

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'test_helper'
require_relative 'collection_serializer_test'

module ActiveModel
  class Serializer
    # Minitest.run_one_method isn't present in minitest 4
    if $minitest_version > 4 # rubocop:disable Style/GlobalVars
      class ArraySerializerTest < CollectionSerializerTest
        extend ActiveSupport::Testing::Stream
        def self.run_one_method(*)
          stderr = (capture(:stderr) do
            super
          end)
          if stderr !~ /Calling deprecated ArraySerializer/
            fail Minitest::Assertion, stderr
          end
        end

        def collection_serializer
          ArraySerializer
        end
      end
    else
      class ArraySerializerTest < ActiveSupport::TestCase
        extend ActiveSupport::Testing::Stream
        def test_json_key_with_root_warns_when_using_array_serializer
          stderr = (capture(:stderr) do
            comment = Comment.new
            post = Post.new
            serializer = ArraySerializer.new([comment, post])
            assert_equal 'comments', serializer.json_key
          end)
          assert_match(/Calling deprecated ArraySerializer/, stderr)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_model_serializers-0.10.0.rc4 test/array_serializer_test.rb