I know there has been a very similar question (Why is JBuilder not returning a response body in JSON when testing RSPEC). I'm testing an API endpoint that returns a JSON response generated by a JBuilder template. The response body is always empty. Some of the responders to the previous question suggested enabling render_views either globally or directly in the test example. From what I understand render_views only works inside controller examples, but mine is not and including render_views does not seem to be affecting anything when included globally and throws an undefined variable error when included directly in the example.
describe "GET /api/v3/shows/:id" do
let!(:show) { FactoryGirl.create(:show) }
let!(:season) { FactoryGirl.create(:season, show_id: show.id) }
it "returns basic metadata for show" do
get_show(show.id, valid_user_credentials(user), valid_partner_credentials(partner))
# debugging
# verify that show exists
puts show.id
puts show.title
puts "Response: #{response.body}"
end
end
The console output:
dmz@miranda|tv_api:shows|$ be rspec spec/integration/api_v3/show_spec.rb
/Users/dmitry/Code/Intrn/watchitnow/spec/support/vcr.rb:9 Disabled noisy VCR missing warnings. This
causes OAuthException 400 errors. TODO: Add OAuth VCR cassettes.
1
Item Title 1
Response:
.***
Has anyone had this issue? Thanks.