【问题标题】:Can't use guard-minitest in Rails不能在 Rails 中使用 guard-minitest
【发布时间】:2017-01-18 02:59:42
【问题描述】:

我开始在我的 Rails 项目中使用MiniTest

当我运行spring rake test 时,测试工作正常。 但我无法通过guard-minitest 运行测试。

bundle exec guard
05:03:24 - INFO - Guard::Minitest 2.4.6 is running, with Minitest::Unit 5.9.0!
05:03:24 - INFO - Running: all tests
Run options: -n spec/apis/user_spec.rb --seed 22566

# Running:



Finished in 0.004998s, 0.0000 runs/s, 0.0000 assertions/s.

0 runs, 0 assertions, 0 failures, 0 errors, 0 skips

05:03:25 - INFO - Guard is now watching at '/Users/ironsand/dev/my_project'

保护文件

guard :minitest, spring: 'spring rake test' do
  watch(%r{^test/models/company_test.rb$})
  watch(%r{^test/(.*)\/?test_(.*)\.rb$})
  watch(%r{^lib/(.*/)?([^/]+)\.rb$})     { |m| "test/#{m[1]}test_#{m[2]}.rb" }
  watch(%r{^test/test_helper\.rb$})      { 'test' }
end

我写了测试文件名目录以避免正则表达式失败。 测试文件在test/models/company_test.rb

我可以在哪里以及如何正确配置以通过警卫观看测试文件?

【问题讨论】:

  • 看起来 guard 正在启动 rspec 而不是 minitest:Run options: -n spec/apis/user_spec.rb --seed 22566
  • @jethroo 保护选项在哪里定义?在Guardfile 中没有这样的配置。
  • 你可以试试spring: 'bundle exec spring rake test'github.com/guard/guard-minitest/issues/…
  • 与为规范设置选项之前相同。 Run options: -n spec/apis/user_spec.rb --seed 4908 如果我将目录名称 spec 更改为 spec_temp 则工作正常,但我想保留文件夹名称。

标签: ruby-on-rails minitest guard


【解决方案1】:

我猜这里的问题在于手表块 你能尝试这样设置块吗:

guard 'minitest', cmd: 'spring rake test' do
  watch('company.rb') { 'company_test.rb' }
  watch('company_test.rb')
enв

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-03
    • 2014-03-07
    • 2013-12-19
    • 2012-07-19
    • 2011-05-01
    • 2013-09-22
    相关资源
    最近更新 更多