Skip to content

Instantly share code, notes, and snippets.

@robheittman
Created January 13, 2011 19:31
Show Gist options
  • Save robheittman/778441 to your computer and use it in GitHub Desktop.
Save robheittman/778441 to your computer and use it in GitHub Desktop.
Rails with MongoDB recipe for our Amazon clusters.
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "mongoid"
Before { DatabaseCleaner.clean }
source 'http://rubygems.org'
gem 'rails', '3.0.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mongoid', "2.0.0.rc.1"
gem 'bson_ext', "1.1.5"
gem 'devise'
gem 'haml'
gem 'flutie'
gem 'formtastic'
gem 'maruku'
gem 'carrierwave'
gem 'fog'
gem 'jquery-rails', '>= 0.2.6'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :development, :test do
gem 'ruby_parser'
gem 'hpricot'
gem 'capybara'
gem 'database_cleaner'
gem 'cucumber-rails'
gem 'cucumber'
gem 'rspec-rails', '>= 2.0.0.beta.10'
gem 'spork'
gem 'launchy'
end
rails new $APP --skip-test --skip-active-record --skip-prototype
cd $APP
# Load up attached Gemfile
bundle install
# Mongoid
rails g mongoid:config
# Load up the attached mongoid.yml
# JQuery
rails g jquery:install
# Testing
rails g rspec:install
# HAML
git submodule add git://github.com/teeparham/rails3_haml_scaffold_generator.git lib/generators/haml
# Edit config/application.rb:
# config.generators do |g|
# g.template_engine :haml
# end
touch config/database.yml
rails g cucumber:skeleton --rspec --capybara
rm config/database.yml
# Further edit config/application.rb:
# config.generators do |g|
# g.template_engine :haml
# g.test_framework :rspec
# end
# Fixup spec/spec_helper.rb for Mongoid using the attached version.
# Add features/support/database_cleaner.rb using the attached version.
# Comment this out in features/support/env.rb:
#
# Cucumber::Rails::World.use_transactional_fixtures = true
# Forms
rake flutie:install
rails g formtastic:install
# Authentication
rails g devise:install
rails g devise User
rails g devise:views
# If you're going to push this to heroku, you want to say:
# heroku config:add BUNDLE_WITHOUT="development:test"
defaults: &defaults
development:
host: localhost
database: $APP_development
test:
host: localhost
database: $APP_test
# set these environment variables on your prod server
production:
uri: <%= ENV['MONGOHQ_URL'] %>
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
require 'database_cleaner'
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
# config.use_transactional_fixtures = true
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "mongoid"
end
config.before(:each) do
DatabaseCleaner.clean
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment