Search code examples
ruby-on-railsrubytddguardpry

How do I configure Guard to skip the Pry prompt and just run my changed test?


I am working on an in-house Rails application running Rails (2.3.18) on Ruby (1.8.7) with tests written in Test::Unit (2.5.4) and Shoulda (2.10.2)

Guard (1.6.2) runs all the tests on startup via guard-test (0.7.0) but it then drops into a Pry (0.9.10) prompt instead of listening for file changes. I do not have Pry in my Gemfile, but it appears in my Gemfile.lock underneath Guard,

The sole reason I am using Guard is to re-run tests as files change, which it does for my gems and other projects... If I hit [enter] all the tests will run, but this takes much longer than just the one file I expect it to run.

guard show :

  all_after_pass : true

  all_on_start   : true

  keep_failed    : true

  test_paths     : ["test"] 

Guardfile :

guard :test do

  watch(%r{^test/.+_test\.rb$})

  watch('test/test_helper.rb')  { "test" }

end

How do I configure Guard to skip the Pry prompt and just run my changed test?


Solution

  • Taken from the Guard Wiki:

    If you are on Mac OS X and have problems with either Guard not reacting to file changes or Pry behaving strangely, then you probably suffer under a Ruby build that uses `libedit` instead of `readline`.

    So I highly recommend to follow the instructions in the Guard wiki and recompile your Ruby version with proper Readline support.

    As alternative you could also use the older Guard version 1.4.0 that comes with the simple gets based interactor, see the old README for supported features of that versions. To get the simple interactor, add

    interactor :simple

    to your Gemfile.