Module: JSONSpectacular::RSpec
- Defined in:
- lib/json_spectacular/rspec.rb
Overview
Module containing JSON helper methods that can be mixed into RSpec test scope
Instance Method Summary collapse
-
#eql_json(expected) ⇒ JSONSpectacular::Matcher
Creates a new JSONSpectacular::Matcher instance so it can be passed to RSpec to match
expectedagainst an actual value. -
#json_response ⇒ Hash{String => Boolean, String, Number, Hash, Array}
Parses the last response body in a Rails RSpec controller or request test as JSON.
Instance Method Details
#eql_json(expected) ⇒ JSONSpectacular::Matcher
Creates a new JSONSpectacular::Matcher instance so it can be passed to RSpec to match expected against an actual value.
34 35 36 |
# File 'lib/json_spectacular/rspec.rb', line 34 def eql_json(expected) JSONSpectacular::Matcher.new(expected) end |
#json_response ⇒ Hash{String => Boolean, String, Number, Hash, Array}
Parses the last response body in a Rails RSpec controller or request test as JSON
14 15 16 17 18 |
# File 'lib/json_spectacular/rspec.rb', line 14 def json_response JSON.parse(response.body) rescue JSON::ParserError '< INVALID JSON RESPONSE >' end |