module ActiveModelSerializers::Test::Serializer
Public Instance Methods
assert_serializer(expectation, message = nil)
click to toggle source
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 %r{\APost.+\Z} # assert that no serializer was rendered assert_serializer nil
# 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
Private Instance Methods
setup_serialization_subscriptions()
click to toggle source
# File lib/active_model_serializers/test/serializer.rb, line 117 def setup_serialization_subscriptions @assert_serializer = AssertSerializer.new @assert_serializer.subscribe end
teardown_serialization_subscriptions()
click to toggle source
# File lib/active_model_serializers/test/serializer.rb, line 122 def teardown_serialization_subscriptions @assert_serializer.unsubscribe end