class ActiveModelSerializersMatchers::AssociationMatcher::KeyCheck
Attributes
key[R]
matcher[R]
Public Class Methods
new(matcher, key)
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 99 def initialize(matcher, key) @matcher = matcher @key = key end
Public Instance Methods
description()
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 112 def description "as #{ key.inspect }" end
fail?()
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 108 def fail? !pass? end
failure_message()
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 116 def failure_message "expected #{ matcher.actual } '#{ matcher.type } #{ matcher.root.inspect }' association to explicitly have key #{ key.inspect } but instead #{ actual_key_string }" end
pass?()
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 104 def pass? actual_key.to_s == key.to_s end
Private Instance Methods
actual_key()
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 122 def actual_key matcher.root_association.options[:key] end
actual_key_string()
click to toggle source
# File lib/active_model_serializers_matchers/association_matcher.rb, line 126 def actual_key_string if actual_key "was #{ actual_key.inspect }" else 'has none' end end