Skip to content

Instantly share code, notes, and snippets.

@shivabhusal
Last active April 16, 2019 16:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save shivabhusal/bbb4fbff211e234257e0741ec80fdaec to your computer and use it in GitHub Desktop.
A Rails template for generating boilerplate configs for any new Rails app; viz. rspec, factory_girl_rails, db-cleaner,annonote etc are preconfigured. It saves me an hour everytime.
gem 'slim-rails'
gem 'sassc-rails'
gem 'any_login'
gem 'active_model_serializers', '~> 0.10.0'
gem 'responders'
gem_group :development do
gem 'annotate'
end
gem_group :development, :test do
gem 'zeus', require: false
gem 'pry'
gem 'rspec-rails'
gem 'figaro'
end
gem_group :test do
gem 'faker'
gem 'database_cleaner'
gem 'factory_girl_rails'
gem 'shoulda-matchers', '~> 3.1'
gem 'rails-controller-testing'
end
environment <<-CONFIG
config.generators do |generators|
generators.test_framework :rspec, fixture: false
generators.javascripts false
generators.helper false
generators.view_specs false
generators.helper_specs false
generators.controller_specs true
generators.model_specs true
generators.fixtures false
generators.stylesheets false
generators.decorator_specs false
generators.decorator false
end
CONFIG
file 'spec/support/database_cleaner_config.rb', <<-CODE
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
end
CODE
file 'spec/support/factory_girl_config.rb', <<-CODE
# this will make `create`, `build` method available directly
# no need to write like `FactoryGirl.create(:blahblah)`
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
CODE
file 'spec/support/shoulda_matcher_config.rb', <<-CODE
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
CODE
run "bundle install"
run "rails g rspec:install"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment