Class: RSpecJSONAPISerializer::Matchers::HaveMetaMatcher

Inherits:
Base
  • Object
show all
Defined in:
lib/rspec_jsonapi_serializer/matchers/have_meta_matcher.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from RSpecJSONAPISerializer::Matchers::Base

Instance Method Details

#as(value) ⇒ Object



15
16
17
18
19
# File 'lib/rspec_jsonapi_serializer/matchers/have_meta_matcher.rb', line 15

def as(value)
  add_submatcher HaveMetaMatchers::AsMatcher.new(expected, value)

  self
end

#as_nilObject



21
22
23
# File 'lib/rspec_jsonapi_serializer/matchers/have_meta_matcher.rb', line 21

def as_nil
  as(nil)
end

#descriptionObject



25
26
27
28
29
# File 'lib/rspec_jsonapi_serializer/matchers/have_meta_matcher.rb', line 25

def description
  description = "serialize meta #{expected}"

  [description, submatchers.map(&:description)].flatten.join(' ')
end

#failure_messageObject



31
32
33
# File 'lib/rspec_jsonapi_serializer/matchers/have_meta_matcher.rb', line 31

def failure_message
  "Expected #{expectation}."
end

#failure_message_when_negatedObject



35
36
37
# File 'lib/rspec_jsonapi_serializer/matchers/have_meta_matcher.rb', line 35

def failure_message_when_negated
  "Did not expect #{expectation}."
end

#matches?(serializer_instance) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
# File 'lib/rspec_jsonapi_serializer/matchers/have_meta_matcher.rb', line 9

def matches?(serializer_instance)
  @serializer_instance = serializer_instance

  has_meta? && submatchers_match?
end