Skip to content

Commit 138212e

Browse files
committed
chore: stop testing Rails secrets
1 parent 2868aeb commit 138212e

File tree

10 files changed

+14
-105
lines changed

10 files changed

+14
-105
lines changed

.github/workflows/rspec.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- ruby: "3.2"
3434
gemfile: "gemfiles/rails7.gemfile"
3535
rbs: 'false'
36-
- ruby: "3.2"
36+
- ruby: "3.3"
3737
gemfile: "gemfiles/railsmaster.gemfile"
3838
rbs: 'false'
3939
- ruby: "3.1"
@@ -69,9 +69,6 @@ jobs:
6969
- name: Run RSpec without rails
7070
run: |
7171
bundle exec rake spec:norails
72-
- name: Run Rails secrets tests for uninitialized app
73-
run: |
74-
bundle exec rake spec:secrets
7572
- name: Run Rails autoload tests
7673
run: |
7774
bundle exec rake spec:autoload

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ end
7373

7474
Using Ruby classes to represent configuration allows you to add helper methods and computed parameters easily, makes the configuration **testable**.
7575

76-
The `anyway_config` gem takes care of loading parameters from **different sources** (YAML, credentials/secrets, environment variables, etc.). Internally, we use a _pipeline pattern_ and provide the [Loaders API](#data-loaders) to manage and [extend](#custom-loaders) its functionality.
76+
The `anyway_config` gem takes care of loading parameters from **different sources** (YAML, credentials, environment variables, etc.). Internally, we use a _pipeline pattern_ and provide the [Loaders API](#data-loaders) to manage and [extend](#custom-loaders) its functionality.
7777

7878
Check out the libraries using Anyway Config for more examples:
7979

@@ -270,7 +270,6 @@ This feature is similar to `Rails.application.config_for` but more powerful:
270270
| Feature | Rails | Anyway Config |
271271
| ------------- |-------------:| -----:|
272272
| Load data from `config/app.yml` |||
273-
| Load data from `secrets` |||
274273
| Load data from `credentials` |||
275274
| Load data from environment |||
276275
| Load data from [other sources](#data-loaders) |||

Rakefile

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ RSpec::Core::RakeTask.new("spec:norails") do |task|
2020
task.verbose = false
2121
end
2222

23-
desc "Run Rails secrets tests for uninitialized app"
24-
RSpec::Core::RakeTask.new("spec:secrets") do |task|
25-
ENV["DO_NOT_INITIALIZE_RAILS"] = "1"
26-
ENV["USE_APP_CONFIGS"] = "0"
27-
ENV["NORAILS"] = "0"
28-
task.rspec_opts = "--order defined --tag secrets"
29-
task.verbose = false
30-
end
31-
3223
desc "Run Rails autoload tests for app/configs"
3324
RSpec::Core::RakeTask.new("spec:autoload") do |task|
3425
ENV["USE_APP_CONFIGS"] = "1"
@@ -107,4 +98,4 @@ namespace :spec do
10798
end
10899

109100
desc "Run the all specs"
110-
task default: %w[rubocop rubocop:md steep spec:norails spec spec:secrets spec:autoload spec:rbs]
101+
task default: %w[rubocop rubocop:md steep spec:norails spec spec:autoload spec:rbs]

spec/config_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def submeta=(val)
455455
end
456456
end
457457

458-
describe "#to_source_trace" do
458+
describe "#to_source_trace", env_kot: false do
459459
let(:conf) { CoolConfig.new }
460460

461461
around do |ex|
@@ -606,7 +606,7 @@ def submeta=(val)
606606
end
607607
end
608608

609-
describe "#pretty_print" do
609+
describe "#pretty_print", env_kot: false do
610610
let(:overrides) { {} }
611611
let(:conf) { CoolConfig.new(overrides) }
612612

spec/dummy/config/application.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
module Dummy
1212
class Application < Rails::Application
13+
config.load_defaults Rails::VERSION::STRING.split(".").take(2).join(".").to_f
1314
config.logger = Logger.new("/dev/null")
1415
config.eager_load = ENV["DO_NOT_INITIALIZE_RAILS"] != "1"
1516

spec/dummy/config/secrets.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

spec/dynamic_config_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
data = Anyway::Config.for(:my_app)
1616
expect(data[:test]).to eq 1
1717
expect(data[:name]).to eq "my_app"
18-
unless NOSECRETS
19-
expect(data[:secret]).to eq "my_secret"
20-
end
2118
expect(data[:credo]).to eq "my_credo" if Rails.application.respond_to?(:credentials)
2219
end
2320

@@ -49,7 +46,6 @@
4946
data = Anyway::Config.for(:my_app)
5047
expect(data[:test]).to eq 1
5148
expect(data[:name]).to eq "my_app"
52-
expect(data[:secret]).to eq "my_secret" unless NOSECRETS
5349
expect(data[:credo]).to eq "my_credo" if Rails.application.respond_to?(:credentials)
5450
expect(data[:credo_local]).to eq "betheone" if Rails.application.respond_to?(:credentials)
5551
end

spec/rails/config_spec.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121

2222
if !NORAILS
2323
if Rails.application.respond_to?(:credentials)
24-
it "load config from secrets and credentials" do
24+
it "load config from credentials" do
2525
expect(conf.user[:name]).to eq "secret man"
26-
expect(conf.meta).to eq("kot" => "leta")
2726
expect(conf.user[:password]).to eq "root"
2827
end
2928

30-
it "sets overrides after loading secrets" do
29+
it "sets overrides after loading" do
3130
config = CoolConfig.new(user: {"password" => "override"})
3231
expect(config.user[:name]).to eq "secret man"
3332
expect(config.user[:password]).to eq "override"
@@ -43,7 +42,7 @@
4342
end
4443
end
4544

46-
context "when using local files" do
45+
context "when using local files", env_kot: false do
4746
around do |ex|
4847
Anyway::Settings.use_local_files = true
4948
ex.run
@@ -52,9 +51,7 @@
5251

5352
it "load config local credentials too" do
5453
expect(conf.user[:name]).to eq "secret man"
55-
unless NOSECRETS
56-
expect(conf.meta).to eq("kot" => "murkot")
57-
end
54+
expect(conf.meta).to eq("kot" => "murkot")
5855
expect(conf.user[:password]).to eq "password"
5956
end
6057
end
@@ -81,7 +78,7 @@
8178
},
8279
"port" => {value: 8080, source: {type: :defaults}},
8380
"meta" => {
84-
"kot" => {value: "leta", source: NOSECRETS ? {type: :env, key: "COOL_META__KOT"} : {type: :secrets}}
81+
"kot" => {value: "leta", source: {type: :env, key: "COOL_META__KOT"}}
8582
}
8683
}
8784
)

spec/rails/loaders/secrets_spec.rb

Lines changed: 0 additions & 39 deletions
This file was deleted.

spec/spec_helper.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@
5151
config.filter_run :focus
5252
config.run_all_when_everything_filtered = true
5353

54-
if NOSECRETS
55-
config.around(:each, type: :config) do |ex|
56-
with_env("COOL_META__KOT" => "leta", &ex)
57-
end
54+
config.around(:each, type: :config) do |ex|
55+
next ex.run if ex.metadata[:env_kot] == false
56+
with_env("COOL_META__KOT" => "leta", &ex)
5857
end
5958

6059
config.order = :random

0 commit comments

Comments
 (0)