Closed tacomanator closed 12 years ago
Unfortunately, this gem doesn't work with guard properly. Apparently it works now with guard-spork, since you don't get any errors on the start but guard-minitest is still broken. The issue is that spork-minitest doesn't support any options like -r
or -e
that the guard is passing.
I have found that it is too complex to fix that and decided to use a Guard MiniTest alternative for testing: Autotest (or ZenTest). Also, I start spork manually. If you still want to use Guard you can try out the original spork-testunit instead of spork-minitest. It is much more complex than mine but should work.
Thanks @semaperepelitsa ... I hadn't tried autotest before, I think I'll give it a spin. Wondering if you were able to get minitest/autotest to use spork? Can't quite figure out how to get the drb option passed in correctly.
There is a code snippet in the bottom of the readme.
Thanks, I missed that before. Did the trick. I also added something to .autotest to run spork if it's not already running. Very kludgy solution I'm sure, but in case anyone is interested (gist: https://gist.github.com/2667886)
require 'socket'
require 'timeout'
def is_port_open?(ip, port)
begin
Timeout::timeout(1) do
begin
s = TCPSocket.new(ip, port)
s.close
return false
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
return true
end
end
rescue Timeout::Error
end
return true
end
if is_port_open?('localhost', 8988)
pid = fork do
`spork`
exit
end
puts "waiting for spork to start"
while is_port_open?('localhost', 8988) do sleep 0.1 end
end
require 'autotest/restart'
require 'autotest/growl'
require 'autotest/fsevent'
require 'turn/autorun'
Autotest.add_hook :initialize do |at|
at.testlib = ".minitest"
end
Autotest.add_hook :all_good do |at|
system "rake rcov_info"
end if ENV['RCOV']
class Autotest
# run tests over drb server (spork)
def make_test_cmd files_to_test
if files_to_test.empty?
"" # no tests to run
else
"testdrb #{files_to_test.keys.join(' ')}"
end
end
end
Very good! One note: you should use spawn "spork"
instead of forking the ruby process and running the command after that.
Not sure where this error is coming from but looking for help to isolate.
I'm trying to add spork (via spork-minitest) to my rails 3.2.3 project which is using minitest and guard. I've added spork-minitest to the gemfile, and generated a spork entry in the guardfile:
I moved all of the code in my test_helper into the Spork.prefork block:
I can then run spork using and see that tests are much faster via
time bundle exec rake test:models --drb
(complains about --drb option, but it takes it anyway).I then try to run the same process through guard via
bundle exec guard
. It starts properly, but errors when running the tests:I'm starting here because spork-minitest is deepest in the stack, and because I verified that guard works properly before attempting to integrate spork.