Ruby on rails 自动测试(Rails)运行的极限集成测试

Ruby on rails 自动测试(Rails)运行的极限集成测试,ruby-on-rails,continuous-integration,autotest,Ruby On Rails,Continuous Integration,Autotest,我正在使用自动测试,并添加了钩子来运行集成测试。工作时,每当我做出影响任何集成测试的更改时,所有集成测试都会重新运行。这是我想要改变的行为,如果可能的话。(我使用rspec和webrat进行测试,没有黄瓜) 对于非集成测试,模式是,如果更改测试或其描述内容,它将在同一规范文件(或描述块?)中重新运行测试。假设我们有page_controller.rb和page_controller_spec.rb。autotest知道,如果您更改其中一个文件,它将只运行page_controller_spec中

我正在使用自动测试,并添加了钩子来运行集成测试。工作时,每当我做出影响任何集成测试的更改时,所有集成测试都会重新运行。这是我想要改变的行为,如果可能的话。(我使用rspec和webrat进行测试,没有黄瓜)

对于非集成测试,模式是,如果更改测试或其描述内容,它将在同一规范文件(或描述块?)中重新运行测试。假设我们有page_controller.rb和page_controller_spec.rb。autotest知道,如果您更改其中一个文件,它将只运行page_controller_spec中的测试,如果通过,它将运行所有测试。我想为我的集成测试做一些类似的事情——只需先运行文件中的测试,测试失败,然后运行所有通过的测试

我的.autotest文件如下所示

require "autotest/growl"
require "autotest/fsevent"

Autotest.add_hook :initialize do |autotest|
  autotest.add_mapping(/^spec\/integration\/.*_spec\.rb$/) do
    autotest.files_matching(/^spec\/integration\/.*_spec\.rb$/)
  end  
end

对不起,我没有时间完全解决您的问题,但我想您可以在阅读Autotest#add#mapping method的评论时自行解决。你必须玩一点正则表达式。注意“+proc+传递了匹配的文件名和Regexp.last_匹配”。以下是完整的评论:

  # Adds a file mapping, optionally prepending the mapping to the
  # front of the list if +prepend+ is true. +regexp+ should match a
  # file path in the codebase. +proc+ is passed a matched filename and
  # Regexp.last_match. +proc+ should return an array of tests to run.
  #
  # For example, if test_helper.rb is modified, rerun all tests:
  #
  #   at.add_mapping(/test_helper.rb/) do |f, _|
  #     at.files_matching(/^test.*rb$/)
  #   end

  def add_mapping regexp, prepend = false, &proc

您的
.autotest
是问题的根源:)它基本上说,对于
/spec/integration
目录中的任何文件,所有文件都应该运行。您应该只返回匹配的文件名,如下所示:

require "autotest/growl"
require "autotest/fsevent"

Autotest.add_hook :initialize do |autotest|
  autotest.add_mapping(/^spec\/integration\/.*_spec\.rb$/) do |filename|
    filename
  end  
end

不是很有帮助。这里的注释有误导性,在这种情况下,他只需要返回匹配的文件名。