Jer*_*ker 5 ruby testing guard minitest
我显然做错了什么.我正在尝试在单个文件中编写和测试纯红宝石.我希望看守文件和测试文件,并在文件更改时随时运行minitest.
所以,有两个文件:game.rb和game_test.rb
game.rb
class Game
end
Run Code Online (Sandbox Code Playgroud)
game_test.rb
require 'rubygems'
require 'minitest/autorun'
require './game'
class GameTest < MiniTest::Unit::TestCase
def test_truth
assert true
end
end
Run Code Online (Sandbox Code Playgroud)
我还有一个看起来像这样的Guardfile:
notification :terminal_notifier
guard 'minitest', test_folders: '.' do
watch('game.rb')
watch('game_test.rb')
end
Run Code Online (Sandbox Code Playgroud)
现在,我可能忘了什么,但我不能为我的生活弄清楚它是什么.
如果我开始守卫并按Enter键,则"全部运行"并且测试运行..至少大部分时间.但是,我必须按Enter键才能实现.
此外,如果我对文件进行更改没有任何反应.我已经尝试将gem'rb-fsevent'放在Gemfile中并使用"bundle exec guard"运行,但这似乎也没有帮助.
任何帮助将非常感激.我疯了.
谢谢,杰里米
小智 5
您的第一个"监视"定义将简单地传递"game.rb",它不是测试文件,因此不会运行.第二个"监视"是正确的,所以当你保存"game_test.rb"时,测试应该运行.
这应该是一个更正确的Guardfile:
notification :terminal_notifier
guard 'minitest', test_folders: '.' do
watch('game.rb') { 'game_test.rb' }
watch('game_test.rb')
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
922 次 |
| 最近记录: |