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!
Wow thanks Nick, been waiting for this!
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”
@Marc: good idea, I should let you configure whether or not to use
rails_spec
in the next version. Ticked filed.Why didn’t you submit this as a patch to ZenTest???
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.
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?
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 :))
@Shakhruz: yeah, you’re right, especially about diff-lcs -- that should be mentioned. I suppose if I used
instead that would be more platform agnostic.
Thanks!
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
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?
@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?
Rad! Thanks!
I’m using @spec_command = “drbspec –diff unified”
which I think is just the new version of script/railsspec
Chris
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!!
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
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?