class RSpecJSONAPISerializer::Matchers::HaveAttributeMatcher

Public Instance Methods

as(value) click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_attribute_matcher.rb, line 15
def as(value)
  add_submatcher HaveAttributeMatchers::AsMatcher.new(expected, value)

  self
end
as_nil() click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_attribute_matcher.rb, line 21
def as_nil
  add_submatcher HaveAttributeMatchers::AsMatcher.new(expected, nil)

  self
end
main_failure_message() click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_attribute_matcher.rb, line 27
def main_failure_message
  "expected #{serializer_name} to have attribute #{expected}." unless has_attribute?
end
matches?(serializer_instance) click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_attribute_matcher.rb, line 9
def matches?(serializer_instance)
  @serializer_instance = serializer_instance

  has_attribute? && submatchers_match?
end

Private Instance Methods

attributes() click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_attribute_matcher.rb, line 33
def attributes
  @attributes ||= serializer_instance.class.try(:attributes_to_serialize) || {}
end
has_attribute?() click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_attribute_matcher.rb, line 37
def has_attribute?
  attributes.has_key?(expected)
end