module RailsStuff::TestHelpers::Response
Public Class Methods
prepare_json_object(object)
click to toggle source
Return `Hashie::Mash` for a given object. When `Array` is given it is mapped to mash recursievly.
# File lib/rails_stuff/test_helpers/response.rb, line 9 def prepare_json_object(object) case object when Hash then Hashie::Mash.new(object) when Array then object.map(&method(__callee__)) else object end end
Public Instance Methods
inspect()
click to toggle source
Makes it easier to debug failed specs.
# File lib/rails_stuff/test_helpers/response.rb, line 37 def inspect "<Response(#{status})>" end
json_body()
click to toggle source
Easy access to json bodies. It parses and return `Hashie::Mash`'es, so properties can be accessed via method calls:
response.json_body.order.items.id # note that hash methods are still present: response.json_body.order[:key] # instead of order.key
# File lib/rails_stuff/test_helpers/response.rb, line 32 def json_body @json_body ||= Response.prepare_json_object(JSON.parse(body)) end