Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rewinfrey/4278794 to your computer and use it in GitHub Desktop.
Save rewinfrey/4278794 to your computer and use it in GitHub Desktop.
How to setup Autotest with Rspec v. 2..
Install the necessary gems:
$ gem install autotest
$ gem install autotest-growl
$ gem install autotest-fsevent
note: you may also need the "autotest-rails-pure" gem
Create ~/.autotest configuration file (include the following script):
# if you have any issues getting this to work (like Growl notifications not appearing),
# take a look at the README found here: http://github.com/svoop/autotest-growl
begin
require 'autotest/growl'
rescue LoadError
warn "Error loading autotest/growl. Run '[sudo] gem install autotest-growl' first."
end
begin
require 'autotest/fsevent'
rescue LoadError
warn "Error loading autotest/fsevent. It switches autotest from constantly polling your hard drive to using OS X's event notification system. Cool!"
warn "Run '[sudo] gem install autotest-fsevent' first."
end
# configuration options
# I find show_modified_files to be way too much clutter on my screen, so I default them to false
Autotest::Growl::show_modified_files = false
Autotest::Growl::hide_label = true
#Autotest::Growl::clear_terminal = false
#Autotest::Growl::sticky_failure_notifications = false
#Autotest::Growl::one_notification_per_run = true
# this is a workaround for growl notifications not popping up
Autotest::Growl::remote_notification = true
# ignore changes to these files
Autotest.add_hook :initialize do |at|
%w{.git .svn .hg .DS_Store ._* log}.each {|exception|at.add_exception(exception)}
end
__END__
OPTIONAL:
Create a ~/.rspec configuration file:
personally, i like my .rspec file to look like this:
-c
--format doc
Configure a project to use Autotest (works for both Ruby and Rails projects):
$ cd project_dir
$ mkdir autotest
$ vim autotest/discovery.rb
add the following to discovery.rb:
Autotest.add_discovery { "rspec2" }
$ autotest
And that should work!
Note: if you are using a different testing engine than rspec version 2, you will want to use that in the discovery.rb file rather than "rspec2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment