2012-10-13 2 views
5

분명히 뭔가 잘못되었습니다. 난 평범한 루비를 하나의 파일로 작성하고 테스트하려고한다. 가드가 파일과 테스트 파일을보고 파일이 변경 될 때마다 minitest를 실행하길 원합니다.하나의 Ruby 파일에 guard-minitest 사용

그래서, 두 개의 파일 : 나는이처럼 보이는 Guardfile이

require 'rubygems' 
require 'minitest/autorun' 
require './game' 

class GameTest < MiniTest::Unit::TestCase 
    def test_truth 
    assert true 
    end 
end 

game.rb 및 game_test.rb

game.rb

class Game 
end 

game_test.rb :

notification :terminal_notifier 

guard 'minitest', test_folders: '.' do 
    watch('game.rb') 
    watch('game_test.rb') 
end 

이제 아마 뭔가를 잊어 버렸지 만, 내 삶에있어 그것이 무엇인지 알아낼 수는 없습니다.

가드를 시작하고 Enter를 누르면 "Run All"이 실행되고 테스트는 적어도 대부분 실행됩니다. 그러나 Enter 키를 눌러야합니다.

또한 파일을 변경하면 아무 일도 일어나지 않습니다. gemfile에 'rb-fsevent'라는 보석을 넣고 "bundle exec exec"로 실행하려고 시도했지만 도움이되지 않습니다.

도움을 주시면 감사하겠습니다. 나는 열매 맺을거야.

감사합니다, 제레미

답변

5

첫 번째 정의는 단순히 실행되지 않도록 테스트 파일이하지 않은, "game.rb"을 전달합니다 "시계". 두 번째 "watch"가 정확하므로 "game_test.rb"를 저장할 때 테스트가 실행되어야합니다. 그래서, 나는 그 시도하고 운이 없었다

notification :terminal_notifier 

guard 'minitest', test_folders: '.' do 
    watch('game.rb') { 'game_test.rb' } 
    watch('game_test.rb') 
end 
+2

:

보다 정확한 Guardfile해야한다. 내가 일할 수 있었던 유일한 것은 watch ('game.rb') { './game_test.rb'}와 상대 디렉토리가있는 것뿐입니다. 나는 왜 그런지 이해하지 못한다. 이견있는 사람? –

+1

위안이라면 같은 문제가 있습니다. 두 파일 (watch ('game.rb') { './game_test.rb'}과 동일한 작업을 수행해야했습니다. watch ('game_test.rb') { './game_test.rb'}} '. –

+0

이상한 점이 있으시면 언제든지 [guard-minitest] (https://github.com/guard/guard-minitest/issues/new)에 문제를보고하십시오. (또한 Guard를 디버그 모드로 실행하십시오. '--debug' 플래그로). 또한 [guard-minitest 's Guardfile 템플릿] (https://github.com/guard/guard-minitest/blob/master/lib/guard/minitest/templates/Guardfile#L3-L5)에서 영감을 얻으시기 바랍니다. . – rymai