rspecでテストを書いていたところ、タイトルのエラーが出てきました
どうやら、rbuy のオブジェクトと、データベースの精度の違いによるもののようです
describe 'GET #show' do
before do
@product = create(:product)
get "/products/#{@product.id}", format: :json
end
it 'returns 200 status' do
expect(response).to be_success
expect(response.status).to eq(200)
end
it 'contains body' do
json = JSON.parse(response.body)
expect(json['data']['id']).to eq(@product.id)
expect(json['data']['height'].to_s).to eq(@product.height.to_s)
expect(json['data']['width'].to_s).to eq(@product.width.to_s)
expect(json['data']['depth'].to_s).to eq(@product.depth.to_s)
expect(json['data']['description']).to eq(@product.description)
end
end
参考にした記事

コメントを残す