rspec and autotest
May 29th, 2007
At RailsConf 2007 in Portland, I had the privilege of sitting down w/ Ryan Davis and working with him to improve the runtime relationship between RSpec and Autotest. David Goodlad was at the table as well, and helped me work out some of the mappings so autotest runs the right examples when you change application code.
<p>The result is that with RSpec >= 1.0.3 and ZenTest >= 3.6.0, you can now use Autotest with RSpec on your Ruby projects, Rails or otherwise, simply by typing “autotest” in the project root. No additional plugins necessary. Sweet.</p>
<p>One gotcha: Some have reported that when an example fails, autotest keeps running it over and over again until you get it to pass. This is due to a conflict between RSpec’s and autotest’s mechanisms for narrowing down the set of files to run. This is easily resolved by removing the following lines from spec/spec.opts:</p>
--format failing_examples:previous_failures.txt --example previous_failures.txt
If you run ‘script/generate rspec’, these lines will not be included in the generated spec.opts file. Otherwise you can just delete them yourself.



May 29th, 2007 at 8:19 am
Hi David,
http://www.ruby-forum.com/topic/109537 ): I am using rspec 1.0.3 (installed in vendor/plugins) and ZenTest 3.6.0. I have written a post about my .autotest config in my blog: http://21croissants.blogspot.com/2007/04/set-up-rspec-on-rails.html
Autotest.add_hook :initialize do |autotest| if autotest.is_a? RspecRailsAutotest autotest.spec_command = ‘script/spec—options spec/spec.opts’ end end
/usr/local/lib/site_ruby/1.8/rubygems.rb:382:in
latest_partials’: undefined method[]’ for nil:NilClass (NoMethodError) from /usr/local/lib/site_ruby/1.8/rubygems.rb:379:inlatest_partials’ from /usr/local/lib/site_ruby/1.8/rubygems.rb:342:inlatest_load_paths’ from /usr/local/lib/site_ruby/1.8/rubygems.rb:341:inlatest_load_paths’ from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:109:inautodiscover’ from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/bin/autotest:36 from /usr/bin/autotest:16May 29th, 2007 at 8:19 am
Jean-Michel – just get rid of your .autotest file and you should be fine. You don’t need it for RSpec-1.0.3 and ZenTest-3.6.0 to play nice together. They just do.
May 29th, 2007 at 8:19 am
You released RSpec 1.0.4 again with an “incompatible” RSpec on Rails version again:
RSpec on Rails : r2008
May 29th, 2007 at 8:19 am
Disregard my previous comment. I had placed the previous plugins in a sub-directory named “OLD” and didn’t realize that Rails was autoloading all subdirectories in vendor/plugins.
May 29th, 2007 at 8:19 am
David,
May 29th, 2007 at 8:19 am
Thanks David for your quick feedback.
On the other hand, I upgraded rubygems from 0.9.2 to 0.94 because I realized I did not have the latest version. it still gives me the same stack trace:
/usr/local/lib/site_ruby/1.8/rubygems.rb:385:in
latest_partials’: undefined method[]’ for nil:NilClass (NoMethodError) from /usr/local/lib/site_ruby/1.8/rubygems.rb:382:inlatest_partials’ from /usr/local/lib/site_ruby/1.8/rubygems.rb:345:inlatest_load_paths’ from /usr/local/lib/site_ruby/1.8/rubygems.rb:344:inlatest_load_paths’ from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:109:inautodiscover’ from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/bin/autotest:36 from /usr/bin/autotest:16(Configure Plugins)
I have posted a comment in the blog of Ryan to ask him.
May 29th, 2007 at 8:19 am
Josh – I got and applied your patch just an hour or so after releasing 1.0.4. It’ll be in 1.0.5.
May 29th, 2007 at 8:19 am
Josh & David:
I had to delete it with rm -Rf and then it almost worked.
$ autotest loading autotest/rails_rspec ./vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb:33:in
initialize’: undefined methodsingularize’ for .svn/text-base/user (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:395:intests_for_file’ from ./vendor/plugins/rspec/lib/autotest/rspec.rb:19:intests_for_file’ from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:319:infind_files_to_test’ from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:318:infind_files_to_test’ from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:373:inreset’ from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:164:inrun’ from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:123:in `run’ from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/bin/autotest:48 from /usr/bin/autotest:16May 29th, 2007 at 8:19 am
On a side note, Ryan wanted to know where did the web_spec gem came from, any idea?
May 29th, 2007 at 8:19 am
Jean-Michel – Glad you and Ryan got that all worked out. Josh submitted a new patch. It wasn’t as simple as replacing the removed require – but it was almost as simple