about me

I'm a 35'ish year old web application developer from South Portland, Maine. I love meeting fellow techies, drop me a line if you want to talk shop.

Categories

Setting up Cucumber/RSpec with Rails 2.3 for Leopard

Posted on 03/13/2009 at 06:58 PM

Update: See comments for resolution to a Nokogiri dependency issue.

Install the gems:

sudo gem install rails --source http://gems.rubyonrails.org
sudo gem install dchelimsky-rspec
sudo gem install dchelimsky
-rspec-rails
sudo gem install cucumber
sudo gem install webrat

Create your app:

rails myapp
cd myapp

Freeze Rails to vendor:

rake rails:freeze:edge

Manage your gem dependencies through rails, edit config/environments/test.rb. Add the following lines:

config.gem "dchelimsky-rspec", :lib => false, :version => ">= 1.1.99.13" 
config.gem "dchelimsky-rspec-rails", :lib => false, :version => ">= 1.1.99.13"
config.gem 'aslakhellesoy-cucumber', :lib => false, :version => ">= 0.1.99.23
config.gem 'webrat', :lib => false

Unpack your gems:

rake gems:unpack RAILS_ENV=test
rake gems
:unpack:dependencies RAILS_ENV=test

And generate your testing folders:

script/generate rspec
script
/generate cucumber

That’s it, have fun.

7 Comments

Comment #1 by CodeOfficer  on  03/14  at  12:29 AM

I ran into one issue after I wrote this.

Nokogiri 1.2.0+ is a gem dependency for Webrat. I already had Nokogiri 1.2.1 installed on my systems /Library gems folder ... and I even unpacked it as a dependency to my apps vendor directory, BUT running ... rake features ... every time resulted in a:

MissingSourceFile: no such file to load—nokogiri/native

For some odd reason, when you unpack Nokogiri from your system to your vendor directory, it copies the gem ... but DOESN’T copy a file called native.bundle. So, I dug into my systems gem folder in:

/Library/Ruby/Gems/1.8/gems/nokogiri-1.2.1

Deep in its /lib folder you will find the ‘native.bundle’ file. Copying the file as-is to the appropriate place in my vendors gem folder made rake features not complain anymore. I generated 2 test afterwards to prove everything was working.

I hope that extra info is of use to someone, it was a real pain to track down.

Comment #2 by CodeOfficer  on  03/14  at  12:39 AM

Also, I believe I had to install the macports version of libxml2 as universal.

sudo port install libxml2 +universal

as seen here:

http://www.iteray.com/archives/133

Comment #3 by CodeOfficer  on  03/14  at  02:50 AM

With some coaxing from technicalpickles in IRC, I’ve just realized that its bad form to vendor native gems ... I’m going to try and un-vendor Nokogiri and see if everything still works as expected.

Comment #4 by Jesse Clark  on  04/16  at  04:01 PM

Just out of curiosity, what reasons did technicalpickles give for it being bad form to vendor native gems?

Comment #5 by Jesse Clark  on  04/16  at  04:04 PM

Oh, wait. One reason just came to me… if I vendor a native extension built on OS X and deploy that app to Ubuntu there might be problems.

Comment #6 by Jesse Clark  on  04/16  at  04:08 PM

Just noticed:
rake gems:build # Build any native extensions for unpacked gems

So, as long as we run this on deployment it shouldn’t be a problem to vendor gems with native extensions.

Did technicalpickles give any other reasons?

Comment #7 by CodeOfficer  on  04/24  at  05:59 PM

That was the only reason I’ve found as well. FYI with the current version of rails you no longer need those specific gem versions in the dchelimsky- and aslakhellesoy- namespaces.

Leave a comment?

Please use Pastie or Gist if you need to write code in your comments.

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?

Please enter the word you see in the image below:


RailsConf 2008 Often times I will release code for free or go that extra distance to help others online. If my skills were useful to you, please consider a small donation. Thank you very much.

recommend me!

Search

You Can Find Me

@ github.com
@ twitter.com
@ calendaraboutnothing

My Wishlists

@ Amazon.com

My Other Sites

Foundation's Edge, RJones Family, We're Not.com (only for staging), Ailee Jones (same as rjones for now)

Friends of Mine

Aaron, Barnaby, Brian, Chris, Dirk, Frank, Four, Justin, Matt, Mike, Monty, Paul, Sean, Travis

IRC Hangouts

I can usually be found lounging on irc.freenode.net while I work, on the following channels: #fauna, #github, #hello-heroku, #jquery, #passenger, #ruby, #rubyonrails, #slicehost, #sproutcore, #textmate, #werenot.