How to: getting a rails 3 beta project set up with Rspec and Cucumber written by: Lee Richmond posted on: 27 March 2010
How to: get a rails 3 beta project set up with Rspec and Cucumberokay so I recently started my first Rails 3 project I knew there was probably going to be one or two issues getting up and running and one of the main issues I found was getting Rspec and Cucumber to play ball with rails 3, but never fear here is how I got everything working.
Step 1: Installing Rails 3 and setting up a new app
I'm not going to go into detail on this step purely because I think that if you can't improve on something then don't try, so for this step I used Ryan Bates' Railscasts on getting started with RVM and Rails 3 Beta which can be found here to get me up and running, For reference I am still using Ruby 1.8.7 for this tutorial and the app I'm building I have called "test_app".
Step 2: Setting up your test environment in your Gemfile
Once I'd done a bit of reading this was actually quite simple, all you need to do as Rails 3 uses bundler as standard is open the Gemfile for your app in TextMate if you are using Mac OSX or any other text editor of your choice and add the following:
1 2 3 4 5 6 7 8 9 10 11 |
group :test do gem "rspec" gem "rspec-rails", ">= 2.0.0.beta.1" gem "faker" gem "machinist" gem "sqlite3-ruby", :require => "sqlite3" gem 'capybara', :git => 'git://github.com/jnicklas/capybara.git' gem 'database_cleaner', :git => 'git://github.com/bmabey/database_cleaner.git' gem 'cucumber-rails', :git => 'git://github.com/aslakhellesoy/cucumber-rails.git' end |
Step 3: its bundling time!
In your terminal window first cd into your application in my case this is:
1 2 |
cd code/test_app |
1 2 3 4 |
bundle install rails g rspec:install rails g cucumber:skeleton --rspec --capybara |
Now if we go and try writing some Cucumber Stories/features and try running them we can see that they work, if you are new to Cucumber I found that once again Ryan Bates' Railscasts on the subject were extremely helpful:
Episode 155: Beginning with Cucumber
Episode 159: More on Cucumber
I hope this blog post helps anyone out there trying to get set up with Cucumber and Rspec in Rails 3.




Simon posted on29 March 2010
Really useful, thanks Lee I shall be giving this a whirl when I get home!