LoginSignup
3
3

More than 5 years have passed since last update.

RequestSpecでJSONの中身を検証する

Posted at
# RequestSpecでJSONの中身を検証
json = JSON.parse(response.body)
json.each do |data|
  keys = data.keys
  expect(keys).to match_array(['id', 'title', 'body'])
  expect(data['id']).to eq(1)
  expect(data['title']).to eq('タイトル')
end
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3