How to test scopes?

后端 未结 2 1682
心在旅途
心在旅途 2021-02-04 04:41

tried to find but with no success. Just wondering how could I test scopes in Rails 3.

Could be using rspec, shoulda or just a test unit.

Thanks.

Actually

2条回答
  •  梦谈多话
    2021-02-04 05:09

    I'm sure there's a more elegant solution, but I've always just set up some objects that should and shouldn't be in my scope. After calling the scope, I check that the returned has the object that it should, and doesn't have the object that it shouldn't.

    If anything, I hope to be enlightened by other answers.

提交回复
热议问题