How to use HTTP status code symbols in RSpec?

后端 未结 4 386
误落风尘
误落风尘 2020-12-29 20:30

I use HTTP status code symbols in code in a controller such as:

render json: {
    auth_token: user.authentication_t         


        
4条回答
  •  太阳男子
    2020-12-29 20:48

    On the one hand, response is built with methods like:

    • success?

    • redirect?

    • unprocessable?

    • full list do: response.methods.grep(/\?/)

    On the other hand, Rspec predicates transforms every foo? method to a be_foo matcher.

    Not sure you can have the 201 this way unfortunately, but creating a custom matcher is quite easy.

    Note Rails test only rely on a few statuses.

提交回复
热议问题