I'm building a Rails backend API and i have a controller that receives post requests. I'm using rspec to make a call to the endpoint and so far it looks like it working. However i am unable to visualise my response. (the controller works and renders the correct JSON). My spec looks like this:
require "spec_helper"
require "rspec_api_documentation/dsl"
resource "Data" do
header "Accept", "application/json"
header "Content-Type", "application/json"
header "Host", "public.example.com"
describe "receives POST request with body", :type => :request do
params = { type: ["1", "2", "3"], fromDate: "26/05/2015", toDate: "30/05/2015" }
post "/api/v1/data/totals", params.to_json
end
end
This test passes, but i don't seem to be able to retrieve the rendered JSON. i've tried putting the following in the describe block:
puts response_body
puts response.body
puts page.body
Does anyone know the correct syntax?
visit
, and then interact with the browser – apneadiving