RSpec Autotest now a Rails Plugin

Posted by Nick Sieger Wed, 15 Nov 2006 15:46:00 GMT

Inspired by a posting on the RSpec list and recent comments stating that my Auto RSpec hack wasn’t working, I’ve bitten the bullet and upgraded to RSpec 0.7.2, and made rspec_autotest a plugin in the process. So, herewith are the necessary incantations to auto-rspec your project. If you’ve tried my hack already, please remove any bits you previously had installed.

  • Install RSpec on Rails, following the original instructions. As of RSpec 0.7.3, the specific version of ZenTest is no longer required. Also, diff-lcs is required to show unified diff output on should == failures.
gem install zentest -v 3.4.1
gem install diff-lcs
gem install rspec
script/plugin install svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_2/vendor/rspec_on_rails/vendor/plugins/rspec
  • Install rspec_autotest
script/plugin install http://svn.caldersphere.net/svn/main/plugins/rspec_autotest
  • Start autotest
rake spec:autotest

Please let me know if you experience any problems!

Tags , ,  | 15 comments | no trackbacks

Comments

  1. Avatar Josh C said about 2 hours later:

    Wow thanks Nick, been waiting for this!

  2. Avatar Marc Beyerlin said 1 day later:

    This is really cool! Thanx for that.

    I recommend using autotest with the railsspecserver. This is much faster. You only have to start a reailsspecserver with:

    script/railsspecserver

    And change the speccommand in rspecautotest to:

    @spec_command = “spec --diff unified”

    @speccommand = “script/railsspec --diff unified”

  3. Avatar Nick said 2 days later:

    @Marc: good idea, I should let you configure whether or not to use rails_spec in the next version. Ticked filed.

  4. Avatar Ryan Davis said 2 days later:

    Why didn’t you submit this as a patch to ZenTest???

  5. Avatar Nick said 2 days later:

    Well, here’s a patch. I’d be happy to have it included in Autotest, I just didn’t know if you guys thought it was appropriate to have it there.

  6. Avatar Akira said 3 days later:

    Is there a way to use the rspec_autotest outside of Rails i.e. generic Ruby code?

    i.e. autotest can automatically pick up code and test files by placing the files in /lib and /test directories, respectively.

    Is there similar functionality with rspec_autotest?

  7. Avatar Shakhruz said 13 days later:

    Hi Nick! Thanks for the plugin! I had to change slashes in rspec_autotest.rake, line 3 : require File.dirname(FILE) + ‘..lib spec_autotest’ and make ‘gem install diff-lcs’

    to make in work on winxp (yes, i’m still there :))

  8. Avatar Nick said 13 days later:

    @Shakhruz: yeah, you’re right, especially about diff-lcs -- that should be mentioned. I suppose if I used

    File.join(File.dirname(__FILE__), "..", "lib", "rspec_autotest")
    

    instead that would be more platform agnostic.

    Thanks!

  9. Avatar Jodi said 30 days later:

    Thank you v-much Nick.

    Just making the leap to rspec on a new project - very happy to continue having autotest - and the growl notification to boot.

    Jodi

  10. Avatar Michael Johnston said 35 days later:

    Since upgrading to rspec 0.7.5, when a currently being worked-on spec passes, autotest no longer reruns the whole suite of tests.

    To rephrase: on first run, autotest runs all specs.

    after editing a file(s) it re-runs the tests for those files.

    If those pass, it USED to then re-run the whole suite of files. But after upgrading to rspec 0.7.5 it no longer does this, rendering it useless as the only way to see the next failing spec to work on is to restart it (or touch everything)

    Has anyone else encountered this problem or have any idea what could be causing it?

  11. Avatar Nick said 36 days later:

    @Michael: I think this is expected behavior for autotest -- I’ve already noticed this and assumed it was standard behavior. The only time autotest reruns the whole suite is after I’ve just fixed a failing test or spec. Is it possible that’s what you’re observing?

  12. Avatar Chris Anderson said 51 days later:

    Rad! Thanks!

    I’m using @spec_command = “drbspec –diff unified”

    which I think is just the new version of script/railsspec

    Chris

  13. Avatar Chris Williams said 86 days later:

    I had to change @spec_command to:

    @spec_command = “spec.cmd --diff unified”

    To get this to run under Windows. Otherwise autotest tried to execute the ruby file directly, which causes an error.

    Otherwise, seems to work so far. Thanks!!

  14. Avatar mitjok said 97 days later:

    installed autotest plugin as described above, but spec:autotest did non appear in rake tasks list.. anyone had such problem? rspec_autotest: r69 RSpec-0.7.5.1 r1395 rspec_on_rails r1515

  15. Avatar Nick said 98 days later:

    mitjok: I haven’t heard of that problem before. You’re saying that it’s missing in rake -T output?

    Can you verify that the vendor/plugins/rspec_autotest/tasks/rspec_autotest.rake file exists and has contents similar to this?

Trackbacks

Use the following link to trackback from your own site:
http://blog.nicksieger.com/articles/trackback/150