class JsonapiSpec::Matchers::HaveJsonapiAttribute
Public Class Methods
new(attribute)
click to toggle source
# File lib/jsonapi_spec/matchers/have_jsonapi_attribute.rb, line 6 def initialize(attribute) @attribute = attribute end
Public Instance Methods
failure_message()
click to toggle source
# File lib/jsonapi_spec/matchers/have_jsonapi_attribute.rb, line 17 def failure_message "Not have a attribute #{@attribute}" end
failure_message_when_negated()
click to toggle source
# File lib/jsonapi_spec/matchers/have_jsonapi_attribute.rb, line 21 def failure_message_when_negated "have jsonapi attribute #{@attribute}" end
matches?(json)
click to toggle source
# File lib/jsonapi_spec/matchers/have_jsonapi_attribute.rb, line 10 def matches?(json) document = parse_jsonapi(json) document['data']['attributes'].key?(@attribute) rescue JSONAPI::Parser::InvalidDocument false end