How to RSpec a Rails JSON API responses with Jbuilder

How to RSpec a Jbuilder response from a Rails JSON API

For rspec-rails users, when testing a controller action that uses Jbuilder as a serializer, and you want to test that the response includes exactly what you expect from the Jbuilder serializer, you need to enable render_views in your specs. That’s because in RSpec, rendering the content of view templates is disabled by default. But when using Jbuilder, you do want to render views because that’s how Jbuilder serializes the response. And that’s what render_views does: it enables view rendering for controllers specs....

2 min Â· Stefanni Brasil