Last active
February 23, 2016 16:22
-
-
Save ToniRib/c9ae717689d84febc8a3 to your computer and use it in GitHub Desktop.
My working document for my rails application template
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
| # Remove the gemfile so we can start with a clean slate otherwise Rails groups | |
| # the gems in a very strange way | |
| remove_file "Gemfile" | |
| add_file "Gemfile" | |
| prepend_to_file "Gemfile" do | |
| "source \"https://rubygems.org\"" | |
| end | |
| # Add all the regular gems | |
| gem "rails", "4.2.5.1" | |
| gem "bootstrap-sass", "~> 3.3.6" | |
| gem "sass-rails", "~> 5.0" | |
| gem "uglifier", ">= 1.3.0" | |
| gem "jquery-rails" | |
| gem "jbuilder", "~> 2.0" | |
| gem "sdoc", "~> 0.4.0", group: :doc | |
| gem "bcrypt", "~> 3.1.7" | |
| gem "figaro" | |
| gem "pg" | |
| gem_group :development, :test do | |
| gem "pry" | |
| gem "rspec-rails", "~> 3.0" | |
| gem "capybara" | |
| gem "database_cleaner" | |
| gem "selenium-webdriver" | |
| gem "factory_girl_rails", "~> 4.0" | |
| gem "shoulda-matchers", "~> 3.1" | |
| end | |
| gem_group :development do | |
| gem "web-console", "~> 2.0" | |
| gem "spring" | |
| gem "quiet_assets" | |
| end | |
| gem_group :test do | |
| gem "simplecov", require: false | |
| end | |
| # Set up figaro | |
| run "bundle exec figaro install" | |
| # Bundle and set up RSpec | |
| run "bundle install" | |
| run "rails generate rspec:install" | |
| # Set up the spec folders for RSpec | |
| run "mkdir spec/models" | |
| run "mkdir spec/controllers" | |
| run "mkdir spec/features" | |
| run "touch spec/factories.rb" | |
| # Inject into the factory girl files | |
| append_to_file "spec/factories.rb" do | |
| "FactoryGirl.define do\nend" | |
| end | |
| insert_into_file "spec/rails_helper.rb", after: "RSpec.configure do |config|\n" do | |
| " config.include FactoryGirl::Syntax::Methods\n" | |
| end | |
| # Set up simplecov | |
| prepend_to_file "spec/spec_helper.rb" do | |
| "require \"simplecov\"\nSimpleCov.start(\"rails\")\n" | |
| end | |
| append_to_file ".gitignore" do | |
| "# Ignore test coverage files from SimpleCov\n/coverage" | |
| end | |
| # Set up Database Cleaner | |
| insert_into_file "spec/rails_helper.rb", after: "RSpec.configure do |config|\n" do | |
| " config.before(:suite) do\n DatabaseCleaner.clean_with(:truncation)\n end\n\n | |
| config.before(:each) do\n DatabaseCleaner.strategy = :transaction\n end\n\n | |
| config.before(:each, :js => true) do\n DatabaseCleaner.strategy = :truncation\n end\n\n | |
| config.before(:each) do\n DatabaseCleaner.start\n end\n\n | |
| config.after(:each) do\n DatabaseCleaner.clean\n end\n\n" | |
| end | |
| gsub_file "spec/rails_helper.rb", | |
| "config.use_transactional_fixtures = true", | |
| "config.use_transactional_fixtures = false" | |
| # Set up Shoulda Matchers | |
| append_to_file "spec/rails_helper.rb" do | |
| "\nShoulda::Matchers.configure do |config|\n config.integrate do |with|\n with.test_framework :rspec\n with.library :rails\n end\nend" | |
| end | |
| # Set up for scss and bootstrap | |
| run "mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss" | |
| run "touch app/assets/stylesheets/custom.scss" | |
| append_to_file "app/assets/stylesheets/application.scss" do | |
| "\n\n@import \"bootstrap-sprockets\";\n@import \"bootstrap\";\n@import \"custom\";" | |
| end | |
| gsub_file "app/assets/stylesheets/application.scss", | |
| "*= require_tree .", | |
| "" | |
| gsub_file "app/assets/stylesheets/application.scss", | |
| "*= require_self", | |
| "" | |
| append_to_file "app/assets/javascripts/application.js" do | |
| "//= require bootstrap-sprockets" | |
| end | |
| insert_into_file "app/views/layouts/application.html.erb", before: "</head>" do | |
| " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">" | |
| end | |
| # Remove the README.rdoc file and add a regular README.markdown file | |
| remove_file "README.rdoc" | |
| add_file "README.md" | |
| # Set up as a git repo and make the first commit | |
| after_bundle do | |
| git :init | |
| git add: '.' | |
| git commit: "-a -m 'Initial commit'" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment