Problem
You would like to start using BDD in a new Ruby on Rails 3 application, and would like to install Webrat, Cucumber and RSpec to your project.
Solution
Follow the steps below (taken from the RSpec Book), for creating a new Rails 3 application and adding the necessary testing frameworks:
- Create your new ruby on rails application:
rails new my_app
- Go to your new application directory:
cd my_app
- Edit your Gemfile to include the following:
group :development, :test do
gem "rspec-rails", ">= 2.0.0"
gem "cucumber-rails", ">= 0.3.2"
gem "webrat", ">= 0.7.2"
end
- Use bundler to install all the gems and dependencies:
bundle install
- Install the rspec files:
script/rails generate rspec:install
- Install the cucumber files:
script/rails generate cucumber:install
- Run the following and you shouldn’t be seeing any errors:
rake db:migrate
rake db:test:prepare
rake spec
rake cucumber