Last active
October 31, 2018 19:33
-
-
Save rujmah/6264101 to your computer and use it in GitHub Desktop.
Generally, default rails template using mongoid, rspec and cucumber.
This file contains 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!' | |
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 'mongoid' | |
gem 'devise' | |
gem_group :development, :test do | |
gem 'simplecov' | |
gem 'guard-rspec' | |
end | |
gem_group :test do | |
gem 'rspec' | |
gem 'rspec-rails' | |
gem 'cucumber' | |
gem 'capybara' | |
gem 'launchy' | |
gem 'cucumber-rails' | |
gem 'factory_girl_rails' | |
gem 'forgery' | |
gem "database_cleaner" | |
gem "mongoid-rspec" | |
gem "email_spec" | |
gem "launchy" | |
gem "shoulda" | |
gem "poltergeist" | |
end | |
gem_group :development do | |
gem 'sextant' | |
gem 'pry-rails' | |
gem 'thin' | |
gem 'quiet_assets' | |
end | |
gem 'figaro' | |
run 'bundle install' | |
run 'rails generate mongoid:config' | |
run 'rails g rspec:install' | |
generators << "g.test_framework :rspec" | |
run 'rails g cucumber:install' | |
# generators << "g.integration_tool :cucumber" | |
run 'rails g figaro:install' | |
# 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 | |
field :name | |
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 => 'passwordplease', :password_confirmation => 'passwordplease' | |
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 'passwordplease'." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment