Skip to content

Commit

Permalink
Improve test app creation
Browse files Browse the repository at this point in the history
- Remove unneeded libraries

Also fixes an issue when running specs against Rails 5.2 / Ruby 2.2
because of a squiggly heredoc in active storage
  • Loading branch information
tagliala committed Aug 31, 2023
1 parent 0fadb08 commit 397eed2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 29 deletions.
14 changes: 13 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,22 @@ task :default => ['testapp:create', :spec]
namespace :testapp do
desc 'Create a dummy rails application for testing in /tmp'
task :create do
options = %w[
--skip-action-cable
--skip-action-text
--skip-active-job
--skip-active-storage
--skip-asset-pipeline
--skip-bundle
--skip-git
--skip-javascript
--skip-sprockets
--skip-webpack-install
]
FileUtils.mkdir_p('tmp/aruba')
Dir.chdir('tmp') do
FileUtils.rm_rf('railsapp')
sh 'rails new railsapp --skip-bundle --skip-javascript --skip-webpack-install --skip-git'
sh "rails new railsapp #{options.join(' ')}"
end
FileUtils.cp_r('spec/fixtures/railsapp/.', 'tmp/railsapp/')
FileUtils.rm('tmp/railsapp/Gemfile')
Expand Down
19 changes: 12 additions & 7 deletions spec/fixtures/railsapp/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
require_relative 'boot'

require 'rails/all'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
# require "active_job/railtie"
require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
require "action_view/railtie"
# require "action_cable/engine"
# require "sprockets/railtie"
# require "rails/test_unit/railtie"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Railsapp
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.active_record.schema_format = :sql
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
end
end
18 changes: 0 additions & 18 deletions spec/fixtures/railsapp/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,9 @@
# Show full error reports.
config.consider_all_requests_local = true

# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true if Rails.version < '7.0'

# Suppress logger output for asset requests.
config.assets.quiet = true if Rails.version < '7.0'

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true

# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end
3 changes: 0 additions & 3 deletions spec/fixtures/railsapp/config/initializers/assets.rb

This file was deleted.

0 comments on commit 397eed2

Please sign in to comment.