QWANtify is excited to announce, effective May 1, 2010, their purchase by Safe Bridge Solutions, Inc. of Madison, WI. Read More »

My Behavior Driven Development Environment

I have had the opportunity this week to start working on an in house Ruby on Rails project. I am thrilled to doing more agile development that I can enjoy more. The last couple of years I have been doing a lot of Java work for companies that don’t practice a lot of agile techniques. I’m looking forward to the productivity of Rails again. While I am working on this project I plan on posting useful information that I learn or relearn along the way. Today I am going to explain how I setup my local BDD environment on my MacBook Pro OS X (Leopard) using Cucumber, RSpec, RCov, and “ZenTest”:http://www.zenspider.com/ZSS/Products/ZenTest/.

Installing Ruby and Ruby Gems


To begin, I want to upgrade to Ruby 1.8.7 from the Max OS X default Ruby 1.8.6. To do this I will compile it from source. First I need to install wget using MacPorts so I can download files from within my terminal window.

sudo port install wget

Now I can use wget to retrieve the version of Ruby I want, which is Ruby 1.8.7-p160. For my purposes, I have created a downloads folder in my home directory that I am working in.

wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.7-p160.tar.gz
tar -xzvf ruby-1.8.7-p160.tar.gz
cd ruby-1.8.7-p160
./configure --prefix=/usr/local --enable-pthread
sudo make
sudo make install

Before install RubyGems, I must first add the ruby install to my PATH and reopen my terminal window. I’m using TextMate but any editor will do when editing the profile.

mate ~/.bash_profile

I need to add the /usr/local/bin and /usr/local/sbin to the PATH variable. I modified my PATH export as shown below. I made sure to add the new /usr/local directories after the /opt/local directories to make sure they wouldn’t interfere with any MacPort installs.

export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:$PATH

Once, I save my .bash_profile, I close my terminal window and open a new one. To make sure the PATH change worked I can check the Ruby version being used.

ruby -v

Here is what the output should look like.

ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-darwin9.6.0]

With the configuration done, I can now install RubyGems. I change back to my downloads folder before downloading gems.

wget http://rubyforge.org/frs/download.php/55066/rubygems-1.3.2.tgz
tar -xzvf rubygems-1.3.2.tgz 
cd rubygems-1.3.2
sudo ruby setup.rb

Install Additional Software


Before continuing, I need to install two pieces of software I will need for my environment later. I need to install Git and SQLite3. Git I will use for my source control repository and I need SQLite3 for my local testing database. I install both using MacPorts.

sudo port install sqlite3
sudo port install git-core

Git will need to be configured a bit. I want to at least set my user name and email address in Git’s global variables.

git config --global user.name "Josh Swan"
git config --global user.email "josh.swan@qwantify.com"

Install Gems


Next I install the following gems:

sudo gem install rails -v2.3.2
sudo gem install sqlite3-ruby -v1.2.4
sudo gem install rspec -v1.2.2
sudo gem install rspec-rails -v1.2.2
sudo gem install webrat -v0.4.4
sudo gem install mocha -v0.9.5
sudo gem install cucumber -v0.3.0
sudo gem install ZentTest -v4.0.0
sudo gem install rcov -v0.8.1.2.0
sudo gem install mongrel -v1.1.5
sudo gem install capistrano -v2.5.5

As you can see, along with Rails I also installed Mongrel for my application server, SQLite 3 for my testing database, and Capistrano for use with deploys later on. The rest of the gems are related to my testing setup. I’ve shown the version number so you can see the version I am installing but you can omit the version numbers if you want to install the latest and greatest gems.

Conclusion

With the gems installed I am all ready to start setting up my rails application, which is what I’ll be blogging about next week. I hope this helps people with setting up their railsBDD environment and please let me know if something doesn’t work for you. Especially if you have solved the problem so I can post an update to help others.

Filed in: Team Member Blog Comments (2)

Comments

#1 - JessicaJap said on May 10, 2009:
Your site displays incorrectly in Firefox, but content excellent! Thank you for your wise words:)
#2 - ArianaGata said on May 13, 2009:
Very nice blog. I totally agree with your thoughts.
Commenting is not available in this section entry.