-
-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add suspenders:development_environment generator
To do: - [ ] Decide which options we want to include from the existing generator - [ ] Decide on the generator name - [ ] Manually test on a real app Reference: https://github.com/thoughtbot/suspenders/blob/55cb5c246fe53aea4cf53436c7c208b40ad13e85/lib/suspenders/generators/app_generator.rb#L80-L92
- Loading branch information
1 parent
cb5dff8
commit eab6dbe
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
lib/generators/suspenders/development_environment_generator.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Suspenders | ||
module Generators | ||
class DevelopmentEnvironmentGenerator < Rails::Generators::Base | ||
def raise_on_missing_assets_in_test | ||
environment "config.assets.raise_runtime_errors = true", env: "test" | ||
end | ||
|
||
def raise_on_missing_assets_in_development | ||
environment "config.assets.raise_runtime_errors = true", env: "development" | ||
end | ||
end | ||
end | ||
end |
47 changes: 47 additions & 0 deletions
47
test/generators/suspenders/development_environment_test.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require "test_helper" | ||
require "generators/suspenders/development_environment_generator" | ||
|
||
module Suspenders | ||
module Generators | ||
class DevelopmentEnvironmentGenerator::DefaultTest < Rails::Generators::TestCase | ||
include Suspenders::TestHelpers | ||
|
||
tests Suspenders::Generators::DevelopmentEnvironmentGenerator | ||
destination Rails.root | ||
setup :prepare_destination | ||
teardown :restore_destination | ||
|
||
test "raise on missing assets in tests" do | ||
run_generator | ||
|
||
assert_file app_root("config/environments/test.rb") do |file| | ||
assert_match( | ||
/^ +config.assets.raise_runtime_errors = true$/, | ||
file | ||
) | ||
end | ||
end | ||
|
||
test "raise on missing assets in development" do | ||
run_generator | ||
|
||
assert_file app_root("config/environments/development.rb") do |file| | ||
assert_match( | ||
/^ +config.assets.raise_runtime_errors = true$/, | ||
file | ||
) | ||
end | ||
end | ||
|
||
def prepare_destination | ||
backup_file "config/environments/test.rb" | ||
backup_file "config/environments/development.rb" | ||
end | ||
|
||
def restore_destination | ||
restore_file "config/environments/test.rb" | ||
restore_file "config/environments/development.rb" | ||
end | ||
end | ||
end | ||
end |