###前提・実現したいこと
RSpecにて、テストコードを作成しているのですが、
以下のエラーメッセージが発生してしまい、困っています。
なぜ、responseがnilになってしまうのかわからないです。
###発生している問題・エラーメッセージ
Failure/Error: expect(response).to have_http_status 200 expected the response to have status code 200 but it was nil
###該当のソースコード
Ruby
1 describe 'POST Request > Success.' do 2 let(:request_header) do 3 { 'content_type' => 'application/json' } 4 end 5 let(:request_body) do 6 { # 取得する条件 } 7 end 8 9 subject do 10 post '/api/v1/hoge/fuga/', request_body, request_header 11 end 12 13 it do 14 subject 15 expect(response).to have_http_status 200 16 end 17 end
###補足情報(言語/FW/ツール等のバージョンなど)
- Rails 4.1.16
- RSpec 3.6
あなたの回答
tips
プレビュー