Sha256: 4bab273489e30f163b0b31f7ae4fc8a880076ba1a4a6737d5adf2633870c2458

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 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 Minitest::Assertions
        def self.run_one_method(*)
          _, stderr = capture_io do
            super
          end
          if stderr !~ /NOTE: ActiveModel::Serializer::ArraySerializer.new is deprecated/
            fail Minitest::Assertion, stderr
          end
        end

        def collection_serializer
          ArraySerializer
        end
      end
    else
      class ArraySerializerTest < ActiveSupport::TestCase
        def test_json_key_with_root_warns_when_using_array_serializer
          _, stderr = capture_io do
            comment = Comment.new
            post = Post.new
            serializer = ArraySerializer.new([comment, post])
            assert_equal 'comments', serializer.json_key
          end
          assert_match(/NOTE: ActiveModel::Serializer::ArraySerializer.new is deprecated/, stderr)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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