class RSpecJSONAPISerializer::Matchers::HaveMetaMatchers::AsMatcher

Attributes

meta[R]

Public Class Methods

new(meta, expected) click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_meta_matchers/as_matcher.rb, line 9
def initialize(meta, expected)
  super(expected)

  @meta = meta
end

Public Instance Methods

failure_message() click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_meta_matchers/as_matcher.rb, line 21
def failure_message
  [expected_message, actual_message].compact.join(", ")
end
matches?(serializer_instance) click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_meta_matchers/as_matcher.rb, line 15
def matches?(serializer_instance)
  @serializer_instance = serializer_instance

  actual == expected
end

Private Instance Methods

actual() click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_meta_matchers/as_matcher.rb, line 37
def actual
  metas[meta]
end
actual_message() click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_meta_matchers/as_matcher.rb, line 33
def actual_message
  "got #{actual.nil? ? 'nil' : actual} instead" if metas.has_key?(meta)
end
expected_message() click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_meta_matchers/as_matcher.rb, line 29
def expected_message
  "expected #{serializer_instance.class.name} to serialize meta #{meta} as #{expected}"
end
metas() click to toggle source
# File lib/rspec_jsonapi_serializer/matchers/have_meta_matchers/as_matcher.rb, line 41
def metas
  @metas ||= serializable_hash.dig(:data, :meta) || {}
end