Skip to content

Instantly share code, notes, and snippets.

@pellegrino
Created April 13, 2011 22:04
Show Gist options
  • Save pellegrino/918533 to your computer and use it in GitHub Desktop.
Save pellegrino/918533 to your computer and use it in GitHub Desktop.
aplication template for test/unit cancan devise
# create rvmrc file
create_file ".rvmrc", "rvm gemset use #{app_name} --create"
gem "haml-rails"
gem "sass"
# hpricot and ruby_parser required by haml
gem "hpricot", :group => :development
gem "ruby_parser", :group => :development
gem "nifty-generators"
gem "simple_form"
gem "jquery-rails"
# authentication and authorization
gem "devise"
gem "cancan"
# factory girl, webrat, autotest for testing
gem "rails3-generators", :group => [ :development ]
gem "factory_girl_rails", :group => [ :development, :test ]
gem "webrat", :group => :test
gem "ffaker", :group => :test
gem "autotest", :group => :test
gem "domino" , :group => :test
run 'bundle install'
rake "db:create", :env => 'development'
rake "db:create", :env => 'test'
generate 'nifty:layout --haml'
remove_file 'app/views/layouts/application.html.erb' # use nifty layout instead
generate 'simple_form:install'
generate 'nifty:config'
remove_file 'public/javascripts/rails.js' # jquery-rails replaces this
create_file "lib/dominos.rb" , "#create your dominos here. check https://github.com/ngauthier/domino"
generate 'jquery:install --ui'
inject_into_file 'test/test_helper.rb', "\require 'factory_girl'", :after => "require 'rails/test_help'"
inject_into_file 'test/test_helper.rb', "\nrequire 'dominos'", :after => "require 'factory_girl'"
inject_into_file 'config/application.rb', :after => "config.filter_parameters += [:password]" do
<<-eos
# Customize generators
config.generators do |g|
g.stylesheets false
g.form_builder :simple_form
g.fixture_replacement :factory_girl, :dir => 'test/factories'
end
eos
end
# authentication and authorization setup
generate "devise:install"
generate "devise User"
generate "devise:views"
rake "db:migrate"
generate "cancan:ability"
# clean up rails defaults
remove_file 'public/index.html'
remove_file 'rm public/images/rails.png'
run 'cp config/database.yml config/database.example'
run "echo 'config/database.yml' >> .gitignore"
# commit to git
git :init
git :add => "."
git :commit => "-a -m 'create initial application'"
say <<-eos
============================================================================
Your new Rails application is ready to go.
Don't forget to scroll up for important messages from installed generators.
eos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment