Skip to content

Instantly share code, notes, and snippets.

@robbl
Forked from kjf/rails31init.md
Created August 24, 2011 12:46
Show Gist options
  • Save robbl/1167982 to your computer and use it in GitHub Desktop.
Save robbl/1167982 to your computer and use it in GitHub Desktop.
Rails 3.1 with Rspec, Cucumber, Factory Girl, Haml, and Simple Form

Rails 3.1 configuration

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

# in Gemfile

gem 'haml-rails'
gem 'simple_form'

group :test do
  gem 'database_cleaner'
  gem 'rspec-rails'
  gem 'factory_girl_rails'
  gem 'cucumber-rails'
  gem 'capybara'
  gem 'launchy'
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
  g.stylesheet_engine :sass
end

config.sass.preferred_syntax = :sass

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
rails g rspec:install
rails g simple_form:install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment