Quickly generate a rails app with the default Wagon configuration using Rails Templates.
Get a minimal rails 5 app ready to be deployed on Heroku with Bootstrap, Simple form and debugging gems.
rails new \
-T --database postgresql \
-m https://raw.githubusercontent.com/lewagon/rails-templates/master/minimal.rb \
CHANGE_THIS_TO_YOUR_RAILS_APP_NAME
Same as minimal plus a Devise install with a generated User
model.
rails new \
-T --database postgresql \
-m https://raw.githubusercontent.com/lewagon/rails-templates/master/devise.rb \
CHANGE_THIS_TO_YOUR_RAILS_APP_NAME
These templates are generated without a test
folder (thanks to the -T
flag). Starting from here, you can add Minitest & Capybara with the following procedure:
# config/application.rb
require "rails/test_unit/railtie" # Un-comment this line
# In the terminal, run:
folders=(controllers fixtures helpers integration mailers models)
for dir in "${folders[@]}"; do mkdir -p "test/$dir" && touch "test/$dir/.keep"; done
cat >test/test_helper.rb <<RUBY
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
fixtures :all
end
RUBY
brew install phantomjs # on OSX only
# Linux: see https://gist.github.com/julionc/7476620
# Gemfile
group :development, :test do
gem 'capybara'
gem 'poltergeist'
gem 'launchy'
gem 'minitest-reporters'
# [...]
end
bundle install
# test/test_helper.rb
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'minitest/reporters'
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
class ActiveSupport::TestCase
fixtures :all
end
require 'capybara/rails'
class ActionDispatch::IntegrationTest
include Capybara::DSL
def teardown
Capybara.reset_sessions!
Capybara.use_default_driver
Warden.test_reset!
end
end
require 'capybara/poltergeist'
Capybara.default_driver = :poltergeist
include Warden::Test::Helpers
Warden.test_mode!