Skip to content

Instantly share code, notes, and snippets.

@oleksiilevzhynskyi
Created February 9, 2012 09:29
Show Gist options
  • Save oleksiilevzhynskyi/1778731 to your computer and use it in GitHub Desktop.
Save oleksiilevzhynskyi/1778731 to your computer and use it in GitHub Desktop.
Rails 3.1 with Rspec, Capybara, Factory Girl, Haml

Set up Gemfile

# in Gemfile

gem 'rails', '3.1.1'

gem 'haml'
gem 'haml-rails', :group => :development

group :test do
  gem 'pickle'
  gem 'launchy'
  gem 'database_cleaner'
  gem 'rails3-generators'
  gem 'rspec-rails', :require => false
  gem 'factory_girl_rails'
  gem 'cucumber-rails'
  gem 'capybara', '~> 1.0.1'
  gem 'capybara-webkit', :git => 'git://github.com/thoughtbot/capybara-webkit.git', :branch => '1.0'
end

Install our gems

bundle install

Configure generators to use the gems we want, and skip view spec generation

# in config/application.rb

config.generators do |g|
  g.test_framework :rspec, :views => false, :fixture => true
  g.fixture_replacement :factory_girl, :dir => 'spec/factories'
  g.template_engine :haml
end

turn on autoloading of lib directory and all its subdirectories

In Rails 3+, the lib directory is no longer autoloaded.

# in config/application.rb
config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += Dir["#{config.root}/lib/**/"]

run install tasks for our gems

rails g cucumber:install --capybara
rails g pickle --paths --email
rails g rspec:install
# in features/support/env.rb
Capybara.default_selector = :css
Capybara.javascript_driver = :webkit
Capybara.ignore_hidden_elements = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment