在使用shoulda之后,很明显,应当不再使用宏(对于首选的匹配器,它们均已弃用),例如:
should_allow_custom_test
不推荐用于以下方面:
should allow_custom_test
但是,我可以找到的所有文档都是通过将它们放在
shoulda_macros
目录中来进行的。我认为使用自定义匹配器也可以完成相同的操作,但应该找不到它们。我正在使用的匹配器位于http://gist.github.com/613522
如何在我的
TestCase
中包含自定义匹配器? 最佳答案
深入研究active_record.rb,看起来匹配器是直接需要进入Test :: Unit :: TestCase的
我认为您的要旨已将其纳入ActiveSupport :: TestCase-不确定是否有帮助...但是可能值得尝试。
从active_record.rb:
module Test # :nodoc: all
module Unit
class TestCase
include Shoulda::ActiveRecord::Helpers
include Shoulda::ActiveRecord::Matchers
include Shoulda::ActiveRecord::Assertions
extend Shoulda::ActiveRecord::Macros
end
end
end