我显然做错了什么。我正在尝试在单个文件中编写和测试纯 ruby。我想让守卫监视文件和测试文件,并在任何文件更改时运行 minitest。
所以,两个文件:game.rb 和 game_test.rb
游戏.rb
class Game
end
游戏测试.rb
require 'rubygems'
require 'minitest/autorun'
require './game'
class GameTest < MiniTest::Unit::TestCase
def test_truth
assert true
end
end
我还有一个如下所示的 Guardfile:
notification :terminal_notifier
guard 'minitest', test_folders: '.' do
watch('game.rb')
watch('game_test.rb')
end
现在,我可能忘记了什么,但我终究无法弄清楚它是什么。
如果我启动 guard 并按 Enter,“全部运行”会发生并且测试会运行……至少大部分时间是这样。但是,我必须按 Enter 键才能发生。
此外,如果我对文件进行更改,则什么也不会发生。我试过将 gem 'rb-fsevent' 放入 Gemfile 并使用“bundle exec guard”运行,但这似乎也无济于事。
任何帮助将不胜感激。我要疯了。
谢谢, 杰里米
最佳答案
您的第一个“watch”定义将简单地传递“game.rb”,它不是测试文件,因此不会运行。 第二个“watch”是正确的,所以当你保存“game_test.rb”时,测试应该运行。
这应该是一个更正确的Guardfile:
notification :terminal_notifier
guard 'minitest', test_folders: '.' do
watch('game.rb') { 'game_test.rb' }
watch('game_test.rb')
end
关于ruby - 在单个 Ruby 文件上使用 guard-minitest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12870935/