Skip to content

Commit

Permalink
Introduce suspenders:production_environment generator
Browse files Browse the repository at this point in the history
  • Loading branch information
crackofdusk committed Dec 22, 2023
1 parent fe5fc93 commit acb443f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/generators/suspenders/production_environment_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Suspenders
module Generators
class ProductionEnvironmentGenerator < Rails::Generators::Base
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require "test_helper"
require "generators/suspenders/production_environment_generator"

module Suspenders
module Generators
class ProductionEnvironmentGenerator::DefaultTest < Rails::Generators::TestCase
include Suspenders::TestHelpers

tests Suspenders::Generators::ProductionEnvironmentGenerator
destination Rails.root
setup :prepare_destination
teardown :restore_destination

test "configures the asset host" do
run_generator
assert_file app_root("config/environments/production.rb") do |file|
assert_match(
/^ +config.asset_host = ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))$/,
file
)
end
end

private

def prepare_destination
backup_file "config/environments/produciton.rb"
end

def restore_destination
restore_file "config/environments/produciton.rb"
end
end
end
end

0 comments on commit acb443f

Please sign in to comment.