Sets config.cache_classes to true in test env #722
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a 🐞 bug fix.
bundle exec rspec
to verify this)I need a little help getting this pull request up to snuff with the standards of this project because I'm editing a template used for the configuration of new apps. I'm not sure what sort of automated tests you want for something like this. Do you want me to try adding the config change that I've already added in the template to
spec/fixtures/demo/config/environments/test.rb
.Also, while this pull request hasn't made any new tests fail for me, I also am strangely unable to get tests passing on master. I've included test results from master and from my branch for comparison purposes. I can create a support forum thread about this issue after creating this pull request, if you'd like. I'm running Ruby 3.2.3 on macOS 14.4.1 (23E224), and my master branch is currently at 82796a7.
Tests failing on master
Failures:
Jets::Dotenv#load! ignores *.local files when JETS_ENV_REMOTE=1
Failure/Error: expect(env["ONLY_REMOTE"]).to eq "1"
expected: "1"
got: nil
(compared using ==)
./spec/lib/jets/dotenv_spec.rb:10:in `block (3 levels) in <top (required)>'
Jets::Dotenv#load! replaces ssm: with SSM parameters prefixed with ///
Failure/Error: expect(env.fetch("AUTENTICATED_URL")).to eq value
KeyError:
key not found: "AUTENTICATED_URL"
./spec/lib/jets/dotenv_spec.rb:31:in `fetch'
./spec/lib/jets/dotenv_spec.rb:31:in `block (3 levels) in <top (required)>'
Jets::Dotenv#load! replaces ssm:/ with SSM parameters from the provided path
Failure/Error: expect(env.fetch("ABSOLUTE_VARIABLE")).to eq value
KeyError:
key not found: "ABSOLUTE_VARIABLE"
./spec/lib/jets/dotenv_spec.rb:54:in `fetch'
./spec/lib/jets/dotenv_spec.rb:54:in `block (3 levels) in <top (required)>'
Jets::Dotenv#load! aborts the process with a helpful error if an SSM parameter is not found at AWS
Failure/Error:
expect { Jets::Dotenv.new.load! }
.to raise_error(SystemExit)
.and output(/Error loading/).to_stderr
...and:
Diff for (output /Error loading/ to stderr):
@@ -1 +1 @@
-/Error loading/
+""
./spec/lib/jets/dotenv_spec.rb:66:in `block (3 levels) in <top (required)>'
Finished in 1.89 seconds (files took 0.73701 seconds to load)
490 examples, 4 failures
Failed examples:
rspec ./spec/lib/jets/dotenv_spec.rb:8 # Jets::Dotenv#load! ignores *.local files when JETS_ENV_REMOTE=1
rspec ./spec/lib/jets/dotenv_spec.rb:13 # Jets::Dotenv#load! replaces ssm: with SSM parameters prefixed with ///
rspec ./spec/lib/jets/dotenv_spec.rb:35 # Jets::Dotenv#load! replaces ssm:/ with SSM parameters from the provided path
rspec ./spec/lib/jets/dotenv_spec.rb:58 # Jets::Dotenv#load! aborts the process with a helpful error if an SSM parameter is not found at AWS
Tests failing on stubbing-fix
Failures:
Jets::Dotenv#load! ignores *.local files when JETS_ENV_REMOTE=1
Failure/Error: expect(env["ONLY_REMOTE"]).to eq "1"
expected: "1"
got: nil
(compared using ==)
./spec/lib/jets/dotenv_spec.rb:10:in `block (3 levels) in <top (required)>'
Jets::Dotenv#load! replaces ssm: with SSM parameters prefixed with ///
Failure/Error: expect(env.fetch("AUTENTICATED_URL")).to eq value
KeyError:
key not found: "AUTENTICATED_URL"
./spec/lib/jets/dotenv_spec.rb:31:in `fetch'
./spec/lib/jets/dotenv_spec.rb:31:in `block (3 levels) in <top (required)>'
Jets::Dotenv#load! replaces ssm:/ with SSM parameters from the provided path
Failure/Error: expect(env.fetch("ABSOLUTE_VARIABLE")).to eq value
KeyError:
key not found: "ABSOLUTE_VARIABLE"
./spec/lib/jets/dotenv_spec.rb:54:in `fetch'
./spec/lib/jets/dotenv_spec.rb:54:in `block (3 levels) in <top (required)>'
Jets::Dotenv#load! aborts the process with a helpful error if an SSM parameter is not found at AWS
Failure/Error:
expect { Jets::Dotenv.new.load! }
.to raise_error(SystemExit)
.and output(/Error loading/).to_stderr
...and:
Diff for (output /Error loading/ to stderr):
@@ -1 +1 @@
-/Error loading/
+""
./spec/lib/jets/dotenv_spec.rb:66:in `block (3 levels) in <top (required)>'
Finished in 1.95 seconds (files took 0.80936 seconds to load)
490 examples, 4 failures
Failed examples:
rspec ./spec/lib/jets/dotenv_spec.rb:8 # Jets::Dotenv#load! ignores *.local files when JETS_ENV_REMOTE=1
rspec ./spec/lib/jets/dotenv_spec.rb:13 # Jets::Dotenv#load! replaces ssm: with SSM parameters prefixed with ///
rspec ./spec/lib/jets/dotenv_spec.rb:35 # Jets::Dotenv#load! replaces ssm:/ with SSM parameters from the provided path
rspec ./spec/lib/jets/dotenv_spec.rb:58 # Jets::Dotenv#load! aborts the process with a helpful error if an SSM parameter is not found at AWS
Summary
This corrects the
cache_classes
setting in the template for test environment files.Context
This fix addresses issue #721.
How to Test
app/controllers/demo_controller.rb
app/utilities/demo_utility.rb
spec/controllers/demo_controller_spec.rb
config/routes.rb
bundle exec rspec spec/controllers/demo_controller_spec.rb
This works on my machine.
Version Changes
Patch (unless this breaks something, of course)