Controller Specs vs Request Specs?

前端 未结 3 1212
伪装坚强ぢ
伪装坚强ぢ 2021-02-03 19:29

I\'m working on a rails API and I\'m now planning on writing some RSpec tests for the controllers. I\'ve been reading around and I haven\'t been able to figure out what the act

3条回答
  •  长发绾君心
    2021-02-03 20:09

    Quoting Aaron Sumner:

    Both the Rails and RSpec teams suggest replacing or removing your app’s controller tests (also known as the functional test layer), in favor of directly testing models (units), or with higher-level integration tests.

    For a new API, I prefer to use request spec and hit my "end points" (aka Models and Business logic) than using controller tests.

提交回复
热议问题