使用 rspec rails 测试 JSON 响应

Test the JSON response using rspec rails

我在 rails(API) 中收到了 JSON 的所有回复。我应该如何使用 rspec gem(CRUD 操作)

测试来自 JSON 的响应

几种方式。

  1. 您可以将其验证为字符串。
  2. 您可以解析 JSON.parse(response) 响应字符串,验证响应的特定元素。

有什么可以推荐的。