config.gem ‘rspec-rails’ on Rails 2.2.2

Posted by jay on November 29, 2008

Update on 5th April 2009:

This rspec-rails gem issue has been fixed and released in rspec-rails milestone “1.2.0”. see details here

If you are still working on Rspec before version 1.20:

After googling, I counld’t find much information about including rspec-rails in the ruby gems config/environment.rb. The only reason I include it in gem dependency is for the sake of continuous integration, to make sure the build platform happy and green.

So, back to the topic. This was related to rspec bug #577 (still an open ticket), if placing the congif gem in this order:

config.gem 'rspec', :lib => "spec", :version => '1.1.11'
config.gem 'rspec-rails', :lib => "spec/rails", :version => '1.1.11'

you will likely to get errors:

/Library/Ruby/Gems/1.8/gems/rspec-1.1.9/lib/spec/runner/options.rb:229:in `files_to_load': File or directory not found: gems (RuntimeError)
    from /Library/Ruby/Gems/1.8/gems/rspec-1.1.9/lib/spec/runner/options.rb:221:in `each'
    from /Library/Ruby/Gems/1.8/gems/rspec-1.1.9/lib/spec/runner/options.rb:221:in `files_to_load'
    from /Library/Ruby/Gems/1.8/gems/rspec-1.1.9/lib/spec/runner/options.rb:98:in `run_examples'
    from /Library/Ruby/Gems/1.8/gems/rspec-1.1.9/lib/spec.rb:21:in `run'
    from /Library/Ruby/Gems/1.8/gems/rspec-1.1.9/lib/spec/runner.rb:191:in `register_at_exit_hook'
    from /usr/bin/rake:19

The ways to get your head around the bug is placing the rspec-rails before the rspc:

config.gem 'rspec-rails', :lib => "spec/rails", :version => '1.1.11'
config.gem 'rspec', :lib => "spec", :version => '1.1.11'

Alternatively, only include rspec-rails would install rspec by default.

RubyGem update on Leopard

Posted by jay on November 27, 2008

I have a RubyGem version 1.2.0 installed on Leopard. If you would like to update RubyGems to a newer version, the RubyGem user guide suggests for modern versions( >0.8.5 ) can use the following command:

gem update --system

But, console told me the 1.2.0 is the latest version – Nothing to update! The work around is to use install rubygem-update:

gem install rubygems-update
update_rubygems

Check installed version:

MBP:~ Jay$ gem --version
1.3.1

So now, I’m able to pull the latest rSpec plugin into my Rails project.