Skip to content

Instantly share code, notes, and snippets.

@RichOrElse
Last active January 18, 2023 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichOrElse/9fada3065b1e8d1a47b5e16aab482f09 to your computer and use it in GitHub Desktop.
Save RichOrElse/9fada3065b1e8d1a47b5e16aab482f09 to your computer and use it in GitHub Desktop.
Rails 7 app template
-a propshaft
--skip-jbuilder
--skip-helper
--skip-test
--template=https://gist.githubusercontent.com/RichOrElse/9fada3065b1e8d1a47b5e16aab482f09/raw/dfb8b7801fdee97037b4ff426e47f3e4af52ef4a/app_template.rb
raw_path = "https://gist.githubusercontent.com/RichOrElse/9fada3065b1e8d1a47b5e16aab482f09/raw"
gem_group :test do
gem "rspec-rails", "~> 6.0"
gem 'shoulda-matchers', '~> 5.0'
gem "database_cleaner", "~> 2.0", ">= 2.0.1", require: false
end
after_bundle do
generate("rspec:install")
uncomment_lines 'spec/rails_helper.rb', /Dir/, verbose: false
get "#{raw_path}/f783acd365e3d9e19b5c8c321a82c0fe9cac3241/request_helpers.rb", "spec/support/request_helpers.rb"
get "#{raw_path}/f783acd365e3d9e19b5c8c321a82c0fe9cac3241/shoulda_matchers.rb", "spec/support/shoulda_matchers.rb"
get "#{raw_path}/97a4ef5a9fb9f47be83e0a2d94c95fbe664a8f0d/database_cleaner.rb", "spec/support/database_cleaner.rb"
git :init
git add: "."
git commit: %Q{ -m 'Initial commit' }
end
require "database_cleaner/active_record"
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.before(:all, type: "model controller request system") do
DatabaseCleaner.clean_with(:truncation)
end
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
end
module RequestHelpers
def json_response
JSON.parse(response.body, symbolize_names: true)
end
end
RSpec.configure do |config|
config.include(RequestHelpers, type: :request)
end
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
# Keep as many of these lines as are necessary:
with.library :active_record
with.library :active_model
end
end
RSpec.configure do |config|
config.include(Shoulda::Matchers::ActiveModel, type: :model)
config.include(Shoulda::Matchers::ActiveRecord, type: :model)
end
@RichOrElse
Copy link
Author

RichOrElse commented Dec 25, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment