Posted by Nick Sieger
Tue, 30 Jan 2007 02:16:00 GMT
I know there has been some demand out there for a version of my RSpec Autotest Rails plugin that works with standalone (non-Rails) projects, so I finally caved and coded it up. I really hope this does finally get accepted as a patch to ZenTest (nudge, nudge), but until it gets a more standard release, do try it out:
- Ensure you have ZenTest installed (
gem install ZenTest
).
- Download the rspec_autotest.rb file here and put it in the
spec
directory of your project.
- Add this snippet of code into your
Rakefile
, and rake spec:autotest
as usual.
namespace :spec do
task :autotest do
require './spec/rspec_autotest'
RspecAutotest.run
end
end
Once again, happy spec’ing, and let me know of any issues you have with it.
Tags autotest, rspec, ruby | 1 comment | no trackbacks
Posted by Nick Sieger
Wed, 13 Sep 2006 20:35:00 GMT
Update: (2 months later) If you’re reading this, you’re probably interested in my Rails plugin for this instead.
Hot off the presses, after a few hours of hacking and tweaking, may I present Auto+RSpec, otherwise known as The Mashup of RSpec on Rails and autotest. This is not an official release of any sort, but “may work for you.” It’s not a clean hack, as it exposes some areas for autotest to grow if the maintainers decide to open it up to alternatives to Test::Unit. After spending a little time looking at the autotest code, I think it would be nice to allow hooks for autotest plugins to define project conventions (i.e., @exceptions
and the #tests_for_file
method) as well as a result parsing API.
For now, if you’re an RSpec on Rails user, you can try this out as follows:
- Install ZenTest if you haven’t already:
sudo gem install ZenTest
.
- Download rspec_autotest.rb and put in your
vendor/plugins/rspec/lib
directory (you did say you’re using RSpec on Rails didn’t you?)
- Download rspec_autotest.rake and put in your
lib/tasks
directory
- Start
autotest
with rake by typing rake spec:autotest
- Note: if you’re using RSpec 0.6, you might have better success with the files located here.
Next steps for this will be to work out whether this code should live in RSpec on Rails or autotest, or some combination of those.
Now, spec’ers, be off in search of that Red/Green/Refactor rhythm of which sage agilists speak!
Bonus tip: add the following code to your .autotest
file to run spec
with rcov
:
Autotest.add_hook :initialize do |at|
if at.respond_to? :spec_command
at.spec_command = %{rcov --exclude "lib/spec/.*" -Ilib --rails "/usr/lib/ruby/gems/1.8/gems/rspec-0.6.0/bin/spec" -- --diff}
end
end
Posted in testing, ruby, rails | Tags autotest, rspec, ruby, testing | 8 comments | no trackbacks