我的模型有default_scope(:order =>'created_at')我的测试(rspec,factory girl,shoulda等)是:
require 'spec/spec_helper.rb'
describe CatMembership do
context "is valid" do
subject { Factory.build(:cat_membership) }
it { should be_valid }
it { should belong_to :cat}
it { should belong_to :cat_group}
it { should have_db_column(:start_date)}
it { should have_db_column(:end_date)}
end
end
Run Code Online (Sandbox Code Playgroud) 我有点不知所措.Rails 3中的Scopes的单元测试是否有意义?
一方面,我正在编写代码,我应该测试该代码.
但是,另一方面,基本上我的所有范围都是微不足道的.检查传递参数的一个变量几乎是我迄今为止最复杂的范围.
scope :author, proc { |author| where(:author_user_id => author }
该代码是微不足道的,并且或多或少地覆盖了实际使用范围的函数.
测试或不测试范围的最佳实践是什么?