class RSpecApi::Matchers::Json::Matcher
Public Instance Methods
description()
click to toggle source
# File lib/rspec-api/matchers/json/matcher.rb, line 14 def description %Q(be valid JSON) end
matches?(response)
click to toggle source
Calls superclass method
# File lib/rspec-api/matchers/json/matcher.rb, line 9 def matches?(response) super && json end
Also aliased as: ==
Private Instance Methods
actual()
click to toggle source
# File lib/rspec-api/matchers/json/matcher.rb, line 20 def actual body end
json()
click to toggle source
# File lib/rspec-api/matchers/json/matcher.rb, line 28 def json @json ||= JSON strip_callback(body), symbolize_names: true rescue JSON::ParserError, JSON::GeneratorError nil end
match()
click to toggle source
# File lib/rspec-api/matchers/json/matcher.rb, line 24 def match 'body' end
strip_callback(text)
click to toggle source
# File lib/rspec-api/matchers/json/matcher.rb, line 34 def strip_callback(text) callback_pattern = %r[^.+?\((.*?)\)$] text =~ callback_pattern ? text.match(callback_pattern)[1] : text end