Last active
January 18, 2023 12:13
-
-
Save RichOrElse/9fada3065b1e8d1a47b5e16aab482f09 to your computer and use it in GitHub Desktop.
Rails 7 app template
This file contains 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
-a propshaft | |
--skip-jbuilder | |
--skip-helper | |
--skip-test | |
--template=https://gist.githubusercontent.com/RichOrElse/9fada3065b1e8d1a47b5e16aab482f09/raw/dfb8b7801fdee97037b4ff426e47f3e4af52ef4a/app_template.rb |
This file contains 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
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 |
This file contains 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
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 |
This file contains 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
module RequestHelpers | |
def json_response | |
JSON.parse(response.body, symbolize_names: true) | |
end | |
end | |
RSpec.configure do |config| | |
config.include(RequestHelpers, type: :request) | |
end |
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generate Rails App with template
Copy .railsrc locally