Why is JBuilder not returning a response body in JSON when testing RSPEC

前端 未结 2 612
有刺的猬
有刺的猬 2021-01-03 19:20

When testing a JSON response from an RSPEC controller test using DHH\'s JBuilder, my response.body is always \"{}\". It works fine in development/production modes AND when

2条回答
  •  死守一世寂寞
    2021-01-03 19:41

    For anyone that is having the same issue. I have figured it out.

    You must call render_views within the controller tests you are doing. If you do that, you should then see a response.body with your JSON contained :)

提交回复
热议问题