在我从事的一个项目中,我将 Shoulda 与 Test::Unit 结合使用。我遇到的问题是我最近改变了这个:
class MyModel < ActiveRecord::Base
validates_presence_of :attribute_one, :attribute_two
end
对此:
class MyModel < ActiveRecord::Base
validates_presence_of :attribute_one
validates_presence_of :attribute_two, :on => :update
end
以前,我的(通过)测试看起来像这样:
class MyModelTest < ActiveSupport::TestCase
should_validate_presence_of :attribute_one, :attribute_two
end
据我所知,没有任何参数should_validate_presence_of
会导致该测试继续通过上面指定的更改。在测试需求时没有放弃应该:attribute_two
,有什么办法解决这个问题吗?