class ActiveModelSerializersMatchers::AssociationMatcher::SerializerCheck

Attributes

matcher[R]
serializer[R]

Public Class Methods

new(matcher, serializer) click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 139
def initialize(matcher, serializer)
  @matcher = matcher
  @serializer = serializer
end

Public Instance Methods

description() click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 152
def description
  "serialized with #{ serializer }"
end
fail?() click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 148
def fail?
  !pass?
end
failure_message() click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 156
def failure_message
  "expected #{ matcher.actual } '#{ matcher.type } #{ matcher.root.inspect }' association to explicitly have serializer #{ serializer } but instead #{ actual_serializer_string }"
end
pass?() click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 144
def pass?
  actual_serializer.to_s == serializer.to_s
end

Private Instance Methods

actual_serializer() click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 162
def actual_serializer
  matcher.root_association.options[:serializer]
end
actual_serializer_string() click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 166
def actual_serializer_string
  if actual_serializer
    "was #{ actual_serializer }"
  else
    "has none"
  end
end