11.28.07

Getting RSpec working on Windows with InstantRails

Posted in Ruby, rails, rspec, testing at 6:00 am by Robert Horvick

Since bringing a copy of my current project down from heroku to test some features I decided to give RSpec a try at the same time.

My gut feeling was to run “gem install rspec”.  So, for the record, that is NOT the way to properly install rspec on a rails site.

To use rspec on a rails site you need to install it as a plugin.

The documentation page on installing RSpec indicates that I should do this be running the following commands from my ruby shell:

ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspecruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails

When I did this nothing happened.  No output whatsoever. 

I tried running the next command on the install guide (output provided):

>ruby script/generate rspec 

Couldn't find 'rspec' generator 

I figured the problem was not having svn installed (let me take a moment here to say that the plugin script could do a better job of indicating this - silent failure smells a lot like success).

I installed downloaded the win32 client binaries from the subversion site http://subversion.tigris.org/downloads/1.4.5-win32/apache-2.2/svn-win32-1.4.5.zip and extracted them to c:\svn  (so c:\svn\bin now contains svn.exe).

In my ruby command shell I added c:\svn\bin to the path (set PATH=%PATH%;c:\svn\bin) and now re-running the plugin installation succeeded (thousands of lines of status scroll by).

Next I ran the following (with output):


C:\InstantRails\rails_apps\kidseatfree>ruby script\generate rspec 

      exists  spec 

  create spec/spec_helper.rb 

      create  spec/spec.opts 

  create previous_failures.txt 

      create  script/spec_server 

      create  script/spec

Finally I ran “rake spec” - which showed I had a missing gem dependency:


C:\InstantRails\rails_apps\kidseatfree>rake spec 

(in C:/InstantRails/rails_apps/kidseatfree) 

C:/InstantRails/rails_apps/kidseatfree/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb:37:in `colour=': You must gem install win32console to use colour on Windows (RuntimeError)

So I ran “gem install win32console” and now rake spec gave the following (I already had an rspec test written so there was something to do):


Errno::ENOENT in 'Deal with fixtures loaded should have one record' 

No such file or directory - C:/InstantRails/rails_apps/kidseatfree/config/../spec/fixtures/deal

So I copied my fixtures from test\fixtures to spec\fixtures and re-ran:


C:\InstantRails\rails_apps\kidseatfree>rake spec 

(in C:/InstantRails/rails_apps/kidseatfree) 

..Finished in 0.166 seconds 

2 examples, 0 failures
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

3 Comments »

  1. Greg said,

    April 10, 2008 at 5:31 am

    Thanks for this. Wasted a whole day trying to install a plugin.

  2. Victor Gollnick said,

    May 30, 2008 at 1:06 pm

    Great job!
    I had the same problem with svn… grrrrrrr
    See ya

  3. Hamilton said,

    June 17, 2008 at 5:46 pm

    I too wasted a whole day doing this. Funny thing was that I was following a tutorial for netbeans that was dated in Feb 2008. Anyways, thanks.

Leave a Comment