Created
November 20, 2010 05:22
-
-
Save cdmwebs/707640 to your computer and use it in GitHub Desktop.
Rails 3 with options for devise, jquery, cucumber, capybara, rspec and mongoid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
generators = [] | |
puts 'Spinning up a new app, captain!' | |
devise = yes?('Use Devise? (yes/no)') | |
jquery = yes?('Use jQuery? (yes/no)') | |
jquery_ui = yes?('Use jQuery UI? (yes/no)') if jquery | |
mongoid = yes?('Use mongoid? (yes/no)') | |
haml = yes?('Use haml? (yes/no)') | |
rspec = yes?('Use Rspec? (yes/no)') | |
machinist = yes?('Use machinist? (yes/no)') | |
cucumber = yes?('Use Cucumber? (yes/no)') | |
capybara = yes?('Use Capybara? (yes/no)') | |
run 'rm public/index.html' | |
run 'rm public/images/rails.png' | |
run 'rm README' | |
run 'touch README' | |
gsub_file 'public/robots.txt', /# User-Agent/, 'User-Agent' | |
gsub_file 'public/robots.txt', /# Disallow/, 'Disallow' | |
gem 'jquery-rails' if jquery | |
gem 'mongoid' if mongoid | |
gem 'bson_ext' if mongoid | |
gem 'haml' if haml | |
gem 'haml-rails' if haml | |
gem 'rspec', :group => :test if rspec | |
gem 'rspec-rails', :group => :development if rspec | |
gem 'fuubar', :group => :test if rspec | |
gem 'cucumber' if cucumber | |
gem 'cucumber-rails', :group => :cucumber if cucumber | |
gem 'capybara', :group => :cucumber if capybara | |
gem 'launchy', :group => :cucumber if capybara | |
gem 'machinist', '>= 2.0.0.beta2', :group => :test if machinist | |
gem 'devise' if devise | |
run 'bundle install' | |
if jquery | |
command = "rails generate jquery:install" | |
command << " --ui" if jquery_ui | |
run command | |
end | |
if mongoid | |
run 'rails generate mongoid:config' | |
end | |
if haml | |
generators << "g.template_engine :haml" | |
end | |
if rspec | |
run 'rails g rspec:install' | |
generators << "g.test_framework :rspec" | |
end | |
if cucumber | |
run 'rails g cucumber:install' | |
generators << "g.integration_tool :cucumber" | |
end | |
if machinist | |
run 'rails generate machinist:install' | |
generators << "g.fixture_replacement :machinist, :dir => '#{rspec ? 'spec/support' : 'test'}/blueprints'" | |
end | |
if devise | |
run 'rails generate devise:install' | |
gsub_file 'config/environments/development.rb', /# Don't care if the mailer can't send/, '### ActionMailer Config' | |
gsub_file 'config/environments/development.rb', /config.action_mailer.raise_delivery_errors = false/ do | |
<<-RUBY | |
config.action_mailer.default_url_options = { :host => 'localhost:3000' } | |
# A dummy setup for development - no deliveries, but logged | |
config.action_mailer.delivery_method = :smtp | |
config.action_mailer.perform_deliveries = false | |
config.action_mailer.raise_delivery_errors = true | |
config.action_mailer.default :charset => "utf-8" | |
RUBY | |
end | |
gsub_file 'config/environments/production.rb', /config.i18n.fallbacks = true/ do | |
<<-RUBY | |
config.i18n.fallbacks = true | |
config.action_mailer.default_url_options = { :host => 'yourhost.com' } | |
### ActionMailer Config | |
# Setup for production - deliveries, no errors raised | |
config.action_mailer.delivery_method = :smtp | |
config.action_mailer.perform_deliveries = true | |
config.action_mailer.raise_delivery_errors = false | |
config.action_mailer.default :charset => "utf-8" | |
RUBY | |
end | |
run 'rails generate devise User' | |
run 'rails generate migration add_name_to_user name:string' | |
gsub_file 'app/models/user.rb', /attr_accessible :email, :password, :password_confirmation, :remember_me/ do | |
<<-RUBY | |
validates_uniqueness_of :email, :case_sensitive => false | |
attr_accessible :name, :email, :password, :password_confirmation, :remember_me | |
RUBY | |
end | |
append_file 'db/seeds.rb' do <<-FILE | |
puts 'SETTING UP DEFAULT USER LOGIN' | |
user = User.create! :name => "New User", :email => '[email protected]', :password => 'please', :password_confirmation => 'please' | |
puts 'New user created: ' << user.name | |
FILE | |
end | |
run 'rake db:migrate' | |
run 'rake db:test:prepare' | |
run 'rake db:seed' | |
end | |
# Configuration | |
generators = <<-GENERATORS | |
config.generators do |g| | |
g.stylesheets false | |
#{generators.join("\n\t\t\t")} | |
end | |
GENERATORS | |
application generators | |
generate(:controller, "home index") | |
gsub_file 'config/routes.rb', /get \"home\/index\"/, 'root :to => "home#index"' | |
git :init | |
git :add => '.' | |
git :commit => "-m 'Initial commit'" | |
if devise | |
puts "Note: Devise is currently using a user's email as an identifier. You may want to change this." | |
puts "The seed user is email '[email protected]' pass 'please'." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to set up your generator configurations. However, I've got an error with having cucumber as the integration_tool. I get "error cucumber [not found]". Is anybody else having this problem?
This is with Rails 3.1.0.rc5 and cucumber-rails 1.0.2.