1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

はじめに

地味にハマってしまい、情報がなかったのでまとめます

問題

Rspecを書いたのですが、なぜかresponse.bodyでエラーが出ました

        
        get :index, format: :json
        res      = JSON.parse(response.body)
     Failure/Error: response      = JSON.parse(response.body)
     
     NoMethodError:
       undefined method `body' for nil:NilClass

解決方法

responseにJSON.parse(response.body) のような未定義の変数に再代入するような形になっていたのが原因だった

        
        get :index, format: :json
        res      = JSON.parse(response.body)

responseをresに変えたらかいけつした

おわりに

これもやりがちな感じがするけどあまりネットにはありませんでした

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?