class JsonapiSpec::Matchers::HaveJsonapiRelationship

Public Class Methods

new(relationship) click to toggle source
# File lib/jsonapi_spec/matchers/have_jsonapi_relationship.rb, line 6
def initialize(relationship)
  @relationship = relationship
end

Public Instance Methods

failure_message() click to toggle source
# File lib/jsonapi_spec/matchers/have_jsonapi_relationship.rb, line 17
def failure_message
  "Not have a relationship #{@relationship}"
end
failure_message_when_negated() click to toggle source
# File lib/jsonapi_spec/matchers/have_jsonapi_relationship.rb, line 21
def failure_message_when_negated
  "have jsonapi relationship #{@relationship}"
end
matches?(json) click to toggle source
# File lib/jsonapi_spec/matchers/have_jsonapi_relationship.rb, line 10
def matches?(json)
  document = parse_jsonapi(json)
  document['data']['relationships'].key?(@relationship)
rescue JSONAPI::Parser::InvalidDocument
  false
end