Rails: Testing named scopes with RSpec

后端 未结 4 1212
滥情空心
滥情空心 2020-12-24 05:40

I am new to testing Rails web applications and RSpec. I work with legacy code and need to add tests. So what is the best way to test finders and named scopes with RSpec?

4条回答
  •  萌比男神i
    2020-12-24 06:45

    The problem with the first approach is that it actually queries the database. It is slow and unnecessary. If you don't mind, you can safely use the first approach. The second approach is fast and clear so I would recommend it.

提交回复
热议问题