Last active
September 20, 2015 02:50
-
-
Save rickbacci/e5803b1f0de90f99bd7f to your computer and use it in GitHub Desktop.
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
rails new myapp -T --database=postgresql | |
# Gemfile | |
source 'https://rubygems.org' | |
ruby '2.2.2' | |
gem 'rails', '4.2.4' | |
gem 'pg' | |
gem "haml-rails", "~> 0.9" | |
gem 'sass-rails', '~> 5.0' | |
gem 'coffee-rails', '~> 4.1.0' | |
gem 'jquery-rails' | |
gem 'bootstrap-sass', '~> 3.2.0' | |
gem 'autoprefixer-rails' | |
gem 'uglifier', '>= 1.3.0' | |
gem 'puma' | |
gem 'figaro' | |
gem 'github_api' | |
group :development, :test do | |
gem 'byebug' | |
gem 'pry' | |
gem 'better_errors' | |
gem 'binding_of_caller' | |
gem 'rspec-rails', '~> 3.0' | |
end | |
group :test do | |
gem 'vcr' | |
gem 'webmock' | |
gem 'simplecov', :require => false | |
gem 'database_cleaner' | |
gem 'capybara' | |
gem 'launchy' | |
end | |
gem 'rails_12factor', group: :production | |
# command line | |
bundle exec figaro install | |
rails generate rspec:install | |
rails generate haml:application_layout convert | |
rake haml:erb2haml ### if erb views are already generated | |
# rails_helper | |
require 'capybara/rails’ | |
require 'database_cleaner' | |
# Database Cleaner | |
http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/ | |
First of all, and this is very important, go into spec/spec_helper.rb and change this line: | |
config.use_transactional_fixtures = true | |
To: | |
config.use_transactional_fixtures = false | |
This will disable rspec-rails’ implicit wrapping of tests in a database transaction. Without disabling this, none of the following configuration will matter. | |
Now configure database_cleaner. I usually create a separate file called spec/support/database_cleaner.rb for this. Inside, I put something like this: | |
RSpec.configure do |config| | |
config.before(:suite) do | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
config.before(:each) do | |
DatabaseCleaner.strategy = :transaction | |
end | |
config.before(:each, :js => true) do | |
DatabaseCleaner.strategy = :truncation | |
end | |
config.before(:each) do | |
DatabaseCleaner.start | |
end | |
config.after(:each) do | |
DatabaseCleaner.clean | |
end | |
end | |
# Puma server | |
Procfile | |
web: bundle exec puma -C config/puma.rb | |
config/puma.rb | |
workers Integer(ENV['WEB_CONCURRENCY'] || 2) | |
threads_count = Integer(ENV['MAX_THREADS'] || 5) | |
threads threads_count, threads_count | |
preload_app! | |
rackup DefaultRackup | |
port ENV['PORT'] || 3000 | |
environment ENV['RACK_ENV'] || 'development' | |
on_worker_boot do | |
# Worker specific setup for Rails 4.1+ | |
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot | |
ActiveRecord::Base.establish_connection | |
end | |
# Bootstrap | |
gem 'bootstrap-sass', '~> 3.3.5' | |
gem 'sass-rails', '>= 3.2' | |
bundle install and restart your server to make the files available through the pipeline. | |
Import Bootstrap styles in app/assets/stylesheets/application.scss: | |
// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables" | |
@import "bootstrap-sprockets"; | |
@import "bootstrap"; | |
bootstrap-sprockets must be imported before bootstrap for the icon fonts to work. | |
Make sure the file has .scss extension (or .sass for Sass syntax). If you have just generated a new Rails app, it may come with a .css file instead. If this file exists, it will be served instead of Sass, so rename it: | |
$ mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss | |
Then, remove all the //= require and //= require_tree statements from the file. Instead, use@import to import Sass files. | |
Do not use //= require in Sass or your other stylesheets will not be able to access the Bootstrap mixins or variables. | |
Require Bootstrap Javascripts in app/assets/javascripts/application.js: | |
//= require jquery | |
//= require bootstrap-sprockets | |
bootstrap-sprockets and bootstrap should not both be included in application.js. | |
bootstrap-sprockets provides individual Bootstrap Javascript files (alert.js or dropdown.js, for example), while bootstrap provides a concatenated file containing all Bootstrap Javascripts. | |
auto-prefixer gem | |
heroku create app | |
figaro heroku:set -e production | |
# in spec_helper.rb | |
require 'simplecov' | |
SimpleCov.start 'rails' | |
require 'vcr' | |
require 'webmock/rspec' | |
VCR.configure do |config| | |
config.hook_into :webmock | |
config.cassette_library_dir = 'spec/support/vcr_cassettes' | |
# config.configure_rspec_metadata! | |
config.default_cassette_options = { serialize_with: :json } | |
config.before_record do |r| | |
r.request.headers.delete("Authorization") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment