代码之家  ›  专栏  ›  技术社区  ›  Sukima

向测试用例添加自定义shoulda匹配器

  •  3
  • Sukima  · 技术社区  · 15 年前

    should_allow_custom_test
    

    不赞成

    should allow_custom_test
    

    但是,我能找到的所有文档都是用于前一个宏设置的,方法是将它们放在 shoulda_macros 目录。我想同样的事情也可以通过一个习惯来实现 匹配器

    http://gist.github.com/613522

    如何包括自定义 匹配器 进入我的 TestCase

    1 回复  |  直到 15 年前
        1
  •  2
  •   Taryn East    15 年前

    深入到active_record.rb,看起来匹配器是Test::Unit::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