Module: ActiveModelSerializers::Test::Serializer

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_model_serializers/test/serializer.rb

Defined Under Namespace

Classes: AssertSerializer

Instance Method Summary collapse

Instance Method Details

#assert_serializer(expectation, message = nil) ⇒ Object

Asserts that the request was rendered with the appropriate serializers.

assert that the "PostSerializer" serializer was rendered

assert_serializer "PostSerializer"

return a custom error message

assert_serializer "PostSerializer", "PostSerializer not rendered"

assert that the instance of PostSerializer was rendered

assert_serializer PostSerializer

assert that the "PostSerializer" serializer was rendered

assert_serializer :post_serializer

assert that the rendered serializer starts with "Post"

assert_serializer %rActiveModelSerializers::Test::Serializer.\APost\APost.+\Z

assert that no serializer was rendered

assert_serializer nil



34
35
36
37
38
39
# File 'lib/active_model_serializers/test/serializer.rb', line 34

def assert_serializer(expectation, message = nil)
  @assert_serializer.expectation = expectation
  @assert_serializer.message = message
  @assert_serializer.response = response
  assert(@assert_serializer.matches?, @assert_serializer.message)
end