Class: RSpecJSONAPISerializer::Matchers::HaveAttributeMatchers::AsMatcher

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

Instance Method Summary collapse

Methods inherited from Base

#failure_message, #failure_message_when_negated

Constructor Details

#initialize(attribute, expected) ⇒ AsMatcher

Returns a new instance of AsMatcher.



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

def initialize(attribute, expected)
  super(expected)

  @attribute = attribute
end

Instance Method Details

#descriptionObject



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

def description
  "as #{expected_to_string}"
end

#expectationObject



25
26
27
# File 'lib/rspec_jsonapi_serializer/matchers/have_attribute_matchers/as_matcher.rb', line 25

def expectation
  [ "as #{expected_to_string}", actual_message ].compact.join(", ")
end

#matches?(serializer_instance) ⇒ Boolean

Returns:

  • (Boolean)


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

def matches?(serializer_instance)
  @serializer_instance = serializer_instance

  actual == expected
end