Skip to content

Instantly share code, notes, and snippets.

@dffuller
Last active August 29, 2015 14:07
Show Gist options
  • Save dffuller/14a7a0b1140204010509 to your computer and use it in GitHub Desktop.
Save dffuller/14a7a0b1140204010509 to your computer and use it in GitHub Desktop.
Using autotest with exercism's Ruby exercises
Autotest.add_hook :initialize do |at|
at.add_mapping %r{^(.*)\.rb$} do |_,m|
at.files_matching( %r{.*_test.rb} )
end
at.add_mapping %r{^.*_test\.rb$} do | file, _|
file
end
end

I spent some time (about 4 hours - I'm stubborn) trying to get Ruby ZenTest's autotest working with the Ruby exercises on http://exercism.io. I finally came across a sample autotest in the Rubinius project that got me moving in the right direction.

To get continuous testing working, copy the autotest.rb file into the project directory (e.g., exercism/ruby/hamming) as .autotest and run autotest at the command line. Then in a separate terminal, edit the files. Each time you save changes to either the test file or the code under test, you should see the tests get re-run.

You should have the ZenTest gem installed. If you're using rbenv, make sure you run rbenv rehash after installing ZenTest so that the shims get updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment