class ActiveModelSerializersMatchers::AssociationMatcher
Attributes
actual[R]
checks[R]
root[R]
type[R]
Public Class Methods
new(root, type)
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 7 def initialize(root, type) @root = root @type = type @checks = [AssociationCheck.new(self, type)] end
Public Instance Methods
as(key)
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 30 def as(key) checks << KeyCheck.new(self, key) self end
description()
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 18 def description checks.map(&:description).join(' ') end
failure_message()
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 22 def failure_message checks.find(&:fail?).failure_message end
matches?(actual)
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 13 def matches?(actual) @actual = actual.is_a?(Class) ? actual : actual.class checks.all?(&:pass?) end
root_association()
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 26 def root_association associations[root] end
serialized_with(serializer)
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 35 def serialized_with(serializer) checks << SerializerCheck.new(self, serializer) self end
Private Instance Methods
associations()
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 42 def associations actual._associations end