【问题标题】:Ruby Autotest with add_mapping使用 add_mapping 进行 Ruby 自动测试
【发布时间】:2009-10-29 17:31:50
【问题描述】:

我正在尝试在 Autotest 中添加一个钩子,以便在更改 javascript 文件时触发测试。

下面是我正在使用的 .autotest 文件。语法似乎是正确的,但更新 javascript 文件时没有任何反应。

第一个钩子工作正常,第二个没有。


Autotest.add_hook :initialize do |at|
  at.add_mapping(%r%^spec/(selenium)/.*rb$%) { |filename, _|
    filename
  }

  at.add_mapping(%r%^public/(javascripts)/.*js$%) do |f, _|
    at.files_matching %r%^spec/(selenium)/.*rb$%
  end
end

【问题讨论】:

    标签: ruby autotest


    【解决方案1】:

    上述代码有效,但是 Rspec Rails discovery.rb 文件添加了一个异常以忽略公共目录。

    在上述autotest 文件中,public/ 的异常需要删除。

     at.remove_exception "public/"
    

    然后添加要忽略的公共文件或目录:

     %w{stylesheets images assets}.each {|exception|at.add_exception(exception)}
    

    我最终得到的是:

    
    Autotest.add_hook :initialize do |at|
    
      at.add_mapping(%r%^spec/(selenium)/.*rb$%) { |filename, _|
        filename
      }
    
      at.remove_exception "public/"
      %w{.git public/stylesheets public/images public/assets}.each {|exception|at.add_exception(exception)}
    
      at.add_mapping(%r%^public/(javascripts)/.*js$%, true) do |f, _|
        (at.files_matching %r%^spec/(selenium)/.*rb$% )
      end
    end
    

    【讨论】:

      猜你喜欢
      • 2010-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多