chamber 2.10.1 → 2.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/chamber/encryption_methods/none.rb +2 -0
  5. data/lib/chamber/version.rb +1 -1
  6. metadata +22 -99
  7. metadata.gz.sig +0 -0
  8. data/spec/fixtures/settings.yml +0 -28
  9. data/spec/lib/chamber/commands/files_spec.rb +0 -24
  10. data/spec/lib/chamber/commands/heroku/clear_spec.rb +0 -12
  11. data/spec/lib/chamber/commands/heroku/compare_spec.rb +0 -12
  12. data/spec/lib/chamber/commands/heroku/pull_spec.rb +0 -12
  13. data/spec/lib/chamber/commands/heroku/push_spec.rb +0 -12
  14. data/spec/lib/chamber/commands/secure_spec.rb +0 -42
  15. data/spec/lib/chamber/commands/show_spec.rb +0 -59
  16. data/spec/lib/chamber/context_resolver_spec.rb +0 -164
  17. data/spec/lib/chamber/file_set_spec.rb +0 -250
  18. data/spec/lib/chamber/file_spec.rb +0 -241
  19. data/spec/lib/chamber/filters/boolean_conversion_filter_spec.rb +0 -57
  20. data/spec/lib/chamber/filters/decryption_filter_spec.rb +0 -252
  21. data/spec/lib/chamber/filters/encryption_filter_spec.rb +0 -195
  22. data/spec/lib/chamber/filters/environment_filter_spec.rb +0 -48
  23. data/spec/lib/chamber/filters/failed_decryption_filter_spec.rb +0 -54
  24. data/spec/lib/chamber/filters/insecure_filter_spec.rb +0 -82
  25. data/spec/lib/chamber/filters/namespace_filter_spec.rb +0 -92
  26. data/spec/lib/chamber/filters/secure_filter_spec.rb +0 -41
  27. data/spec/lib/chamber/filters/translate_secure_keys_filter_spec.rb +0 -39
  28. data/spec/lib/chamber/namespace_set_spec.rb +0 -129
  29. data/spec/lib/chamber/settings_spec.rb +0 -390
  30. data/spec/lib/chamber/types/secured_spec.rb +0 -70
  31. data/spec/lib/chamber_spec.rb +0 -314
  32. data/spec/rails-2-test/config.ru +0 -0
  33. data/spec/rails-2-test/config/application.rb +0 -6
  34. data/spec/rails-2-test/script/console +0 -0
  35. data/spec/rails-3-test/config.ru +0 -0
  36. data/spec/rails-3-test/config/application.rb +0 -6
  37. data/spec/rails-3-test/script/rails +0 -0
  38. data/spec/rails-4-test/bin/rails +0 -0
  39. data/spec/rails-4-test/config.ru +0 -0
  40. data/spec/rails-4-test/config/application.rb +0 -6
  41. data/spec/rails-engine-test/spec/dummy/config.ru +0 -0
  42. data/spec/rails-engine-test/spec/dummy/config/application.rb +0 -5
  43. data/spec/rails-engine-test/spec/dummy/script/rails +0 -0
  44. data/spec/spec_key +0 -27
  45. data/spec/spec_key.pub +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 959b4b9e6ff23b68e96e341093f332e4c07cf6b1
4
- data.tar.gz: 56bd90abf4fcee09212caf6baac48e4d8ef1875b
3
+ metadata.gz: 9edabd92ed2fb227cb36bef070841da66a318d4e
4
+ data.tar.gz: 773b623a400e9135391616bd93bd9b4b07ca8b87
5
5
  SHA512:
6
- metadata.gz: e1c28eba8eb36146d3b0ebe4c697b89509e467b42e5e5492020c02cf989543948bacfc23e6990f9e649759c7ee77d496c59f35b5610cdffdb4b545617f2c8f90
7
- data.tar.gz: 618440410d762ae5a55d169ea452697eaf8433583e5c166706df2f5079051c7381181333e5608bfb0ac81ce91732a9d1fe7201a6894baa5dc9dc0d8d07a454b3
6
+ metadata.gz: 8986c275bcf25008895491027fff6015dd7ea0a0685e428e0b2464d62a9e5a9c96d22938a9d12469cb48c63a2de794467701e5dd7c1a1b38daa3e7bfe13d3190
7
+ data.tar.gz: ab14d195f86e79e1f974f38bb6a73c3b2bee9437a82fe47fbb54c0290821720df364be375cbbb8fcdb92d271c430e2e6ed17c5edd2468eb2a4e3b2a862fec7d8
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -6,6 +6,8 @@ class None
6
6
  end
7
7
 
8
8
  def self.decrypt(key, value, _decryption_key)
9
+ return value if value.nil?
10
+
9
11
  warn "WARNING: It appears that you would like to keep your information for #{key} " \
10
12
  "secure, however the value for that setting does not appear to be encrypted. " \
11
13
  "Make sure you run 'chamber secure' before committing."
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Chamber
3
- VERSION = '2.10.1'.freeze
3
+ VERSION = '2.10.2'.freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chamber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.1
4
+ version: 2.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - thekompanee
@@ -15,26 +15,26 @@ cert_chain:
15
15
  -----BEGIN CERTIFICATE-----
16
16
  MIIDrjCCApagAwIBAgIBATANBgkqhkiG9w0BAQUFADBOMRowGAYDVQQDDBFhY2Nv
17
17
  dW50c19ydWJ5Z2VtczEbMBkGCgmSJomT8ixkARkWC3RoZWtvbXBhbmVlMRMwEQYK
18
- CZImiZPyLGQBGRYDY29tMB4XDTE2MDQyNDAyNTEyM1oXDTE3MDQyNDAyNTEyM1ow
18
+ CZImiZPyLGQBGRYDY29tMB4XDTE3MDgwMjIyNTYzMVoXDTE4MDgwMjIyNTYzMVow
19
19
  TjEaMBgGA1UEAwwRYWNjb3VudHNfcnVieWdlbXMxGzAZBgoJkiaJk/IsZAEZFgt0
20
20
  aGVrb21wYW5lZTETMBEGCgmSJomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEB
21
- BQADggEPADCCAQoCggEBANklzdaVeHtut6LTe/hrl6Krz2Z60InEbNb+TMG43tww
22
- jBpWZrdU/SBkR3EYbTAQv/yGTuMHoVKGK2kDlFvdofW2hX0d14qPyYJUNYt+7VWE
23
- 3UhPSxw1i6MxeU1QwfkIyaN8A5lj0225+rwI/mbplv+lSXPlJEroCQ9EfniZD4jL
24
- URlrHWl/UejcQ32C1IzBwth3+nacrO1197v5nSdozFzQwm4groaggXn9F/WpThu+
25
- MhcE4bfttwEjAfU3zAThyzOFoVPpACP+SwOuyPJSl02+9BiwzeAnFJDfge7+rsd5
26
- 64W/VzBIklEKUZMmxZwr5DwpSXLrknBDtHLABG9Nr3cCAwEAAaOBljCBkzAJBgNV
27
- HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUP7v0f/qfa0LMrhkzHRI3l10X
28
- LYIwLAYDVR0RBCUwI4EhYWNjb3VudHMrcnVieWdlbXNAdGhla29tcGFuZWUuY29t
21
+ BQADggEPADCCAQoCggEBAMc4QXE2KJeQa7s4KChv4ZAfRhflgunXNocdi2rDNCTv
22
+ wLkjoNxDCSkKj8C95dSZVwMy92DqdIbC7ppVTfApXbRxB7BoeY7fWf0EmOQUZ2aa
23
+ FS7QR1OrSVkxZ0rJ6B90ANl8DATLbg/xlw5vxiI/OMva5qt1W2Lmwy6Rl+R6Fr2W
24
+ z90rabN3hQE6J8UItT06QENBWtkypCAjb3fZ513/lw/BvM3vJjZ4/J/dLLHsbmqw
25
+ k6WCuasYf2+Fv7O3/ffdVqKtudf4/Y9B1vVEYIaxoxtsm1UHvVWm+RphyXgsSLe7
26
+ UjoAVW+m0wft3rsmuV1BC9mpUztNATGqYLrpPcoN66cCAwEAAaOBljCBkzAJBgNV
27
+ HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUxAKay6wGYqob8tw4Nr2GP31+
28
+ NckwLAYDVR0RBCUwI4EhYWNjb3VudHMrcnVieWdlbXNAdGhla29tcGFuZWUuY29t
29
29
  MCwGA1UdEgQlMCOBIWFjY291bnRzK3J1YnlnZW1zQHRoZWtvbXBhbmVlLmNvbTAN
30
- BgkqhkiG9w0BAQUFAAOCAQEASqdfJKMun1twosHfvdDH7Vgrb5VqX28qJ6MgnhjF
31
- p+3HYTjYo/KMQqu78TegUFO5xQ4oumU0FTXADW0ryXZvUGV74M0zwqpFqeo8onII
32
- lsVsWdMCLZS21M0uCQmcV+OQMNxL8jV3c0D3x9Srr9yO4oamW3seIdb+b9RfhmV2
33
- ryr+NH8U/4xgzdJ4hWV4qk93nwigp4lwJ4u93XJ7Cdyw7itvaEPnn8HpCfzsiLcw
34
- QwSfDGz6+zsImi5N3UT71+mk7YcviQSgvMRl3VkAv8MZ6wcJ5SQRpf9w0OeFH6Ln
35
- nNbCoHiYeXX/lz/M6AIbxDIZZTwxcyvF7bdrQ2fbH5MsfQ==
30
+ BgkqhkiG9w0BAQUFAAOCAQEAekAixhDiCyu4LvqVIEfNkb9DSCsNUQOCgwX2ppj5
31
+ dfOq0yEABaMNGs5QJZUGXwXI5PHfSrsh8yNXUvofB9A5CE/M7z1nqifAYyjBhQse
32
+ trwZaMUUjIkPVYBCBHnIIRV5r3nQaJRJSBejcJ9rZBiPB+Fy8pumpxTQ4iD28bVh
33
+ z3hlqH0da2pJJ8dJpGka9VS5RJMljl4CmPGfp0xBhaP8SiQ0ROudY2hl41CxoM4u
34
+ D+octMUn1lW1R5TY2r8c6lPvU4otU+9/N9CQP/qPfjpfdjndm4AT9WOElnbqouuF
35
+ CI6ZwNuD9jNYJxrNrpdkOUZVPEr6PoPdArhjNQevWG3zbg==
36
36
  -----END CERTIFICATE-----
37
- date: 2017-02-09 00:00:00.000000000 Z
37
+ date: 2017-12-30 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: thor
@@ -120,10 +120,9 @@ dependencies:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
122
  version: '5.0'
123
- description: "\n Chamber lets you source your Settings from
124
- an arbitrary number of YAML files and\n provides a simple
125
- mechanism for overriding settings from the ENV, which is\n friendly
126
- to how Heroku addons work.\n "
123
+ description: Chamber lets you source your Settings from an arbitrary number of YAML
124
+ files and provides a simple mechanism for overriding settings from the ENV, which
125
+ is friendly to how Heroku addons work.
127
126
  email: hello@thekompanee.com
128
127
  executables:
129
128
  - chamber
@@ -179,44 +178,6 @@ files:
179
178
  - lib/chamber/settings.rb
180
179
  - lib/chamber/types/secured.rb
181
180
  - lib/chamber/version.rb
182
- - spec/fixtures/settings.yml
183
- - spec/lib/chamber/commands/files_spec.rb
184
- - spec/lib/chamber/commands/heroku/clear_spec.rb
185
- - spec/lib/chamber/commands/heroku/compare_spec.rb
186
- - spec/lib/chamber/commands/heroku/pull_spec.rb
187
- - spec/lib/chamber/commands/heroku/push_spec.rb
188
- - spec/lib/chamber/commands/secure_spec.rb
189
- - spec/lib/chamber/commands/show_spec.rb
190
- - spec/lib/chamber/context_resolver_spec.rb
191
- - spec/lib/chamber/file_set_spec.rb
192
- - spec/lib/chamber/file_spec.rb
193
- - spec/lib/chamber/filters/boolean_conversion_filter_spec.rb
194
- - spec/lib/chamber/filters/decryption_filter_spec.rb
195
- - spec/lib/chamber/filters/encryption_filter_spec.rb
196
- - spec/lib/chamber/filters/environment_filter_spec.rb
197
- - spec/lib/chamber/filters/failed_decryption_filter_spec.rb
198
- - spec/lib/chamber/filters/insecure_filter_spec.rb
199
- - spec/lib/chamber/filters/namespace_filter_spec.rb
200
- - spec/lib/chamber/filters/secure_filter_spec.rb
201
- - spec/lib/chamber/filters/translate_secure_keys_filter_spec.rb
202
- - spec/lib/chamber/namespace_set_spec.rb
203
- - spec/lib/chamber/settings_spec.rb
204
- - spec/lib/chamber/types/secured_spec.rb
205
- - spec/lib/chamber_spec.rb
206
- - spec/rails-2-test/config.ru
207
- - spec/rails-2-test/config/application.rb
208
- - spec/rails-2-test/script/console
209
- - spec/rails-3-test/config.ru
210
- - spec/rails-3-test/config/application.rb
211
- - spec/rails-3-test/script/rails
212
- - spec/rails-4-test/bin/rails
213
- - spec/rails-4-test/config.ru
214
- - spec/rails-4-test/config/application.rb
215
- - spec/rails-engine-test/spec/dummy/config.ru
216
- - spec/rails-engine-test/spec/dummy/config/application.rb
217
- - spec/rails-engine-test/spec/dummy/script/rails
218
- - spec/spec_key
219
- - spec/spec_key.pub
220
181
  - templates/settings.yml
221
182
  homepage: https://github.com/thekompanee/chamber
222
183
  licenses:
@@ -239,47 +200,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
200
  version: '0'
240
201
  requirements: []
241
202
  rubyforge_project:
242
- rubygems_version: 2.6.8
203
+ rubygems_version: 2.6.14
243
204
  signing_key:
244
205
  specification_version: 4
245
206
  summary: A surprisingly configurable convention-based approach to managing your application's
246
207
  custom configuration settings.
247
- test_files:
248
- - spec/fixtures/settings.yml
249
- - spec/lib/chamber/commands/files_spec.rb
250
- - spec/lib/chamber/commands/heroku/clear_spec.rb
251
- - spec/lib/chamber/commands/heroku/compare_spec.rb
252
- - spec/lib/chamber/commands/heroku/pull_spec.rb
253
- - spec/lib/chamber/commands/heroku/push_spec.rb
254
- - spec/lib/chamber/commands/secure_spec.rb
255
- - spec/lib/chamber/commands/show_spec.rb
256
- - spec/lib/chamber/context_resolver_spec.rb
257
- - spec/lib/chamber/file_set_spec.rb
258
- - spec/lib/chamber/file_spec.rb
259
- - spec/lib/chamber/filters/boolean_conversion_filter_spec.rb
260
- - spec/lib/chamber/filters/decryption_filter_spec.rb
261
- - spec/lib/chamber/filters/encryption_filter_spec.rb
262
- - spec/lib/chamber/filters/environment_filter_spec.rb
263
- - spec/lib/chamber/filters/failed_decryption_filter_spec.rb
264
- - spec/lib/chamber/filters/insecure_filter_spec.rb
265
- - spec/lib/chamber/filters/namespace_filter_spec.rb
266
- - spec/lib/chamber/filters/secure_filter_spec.rb
267
- - spec/lib/chamber/filters/translate_secure_keys_filter_spec.rb
268
- - spec/lib/chamber/namespace_set_spec.rb
269
- - spec/lib/chamber/settings_spec.rb
270
- - spec/lib/chamber/types/secured_spec.rb
271
- - spec/lib/chamber_spec.rb
272
- - spec/rails-2-test/config/application.rb
273
- - spec/rails-2-test/config.ru
274
- - spec/rails-2-test/script/console
275
- - spec/rails-3-test/config/application.rb
276
- - spec/rails-3-test/config.ru
277
- - spec/rails-3-test/script/rails
278
- - spec/rails-4-test/bin/rails
279
- - spec/rails-4-test/config/application.rb
280
- - spec/rails-4-test/config.ru
281
- - spec/rails-engine-test/spec/dummy/config/application.rb
282
- - spec/rails-engine-test/spec/dummy/config.ru
283
- - spec/rails-engine-test/spec/dummy/script/rails
284
- - spec/spec_key
285
- - spec/spec_key.pub
208
+ test_files: []
metadata.gz.sig CHANGED
Binary file
@@ -1,28 +0,0 @@
1
- ---
2
- development:
3
- my_setting: my_dev_value
4
- my_boolean: 'false'
5
- my_dynamic_setting: 3
6
- another_level:
7
- setting_one: 1
8
- setting_two: 4
9
- level_three:
10
- an_array:
11
- - item 8
12
- - item 2
13
- - item 0
14
- a_scalar: hello
15
- test:
16
- my_setting: my_value
17
- _secure_my_secure_settings: 'M3yI2fIHsfD+zznsvO3FB/ryCwvvdQQ9ZXPQlTIR6Y9vtzNFAeRAxZpSyYUdOpeMDkWQSo5ZVLseM20iTh1YpNCjzd7D0bT4O9aBskYBE92b4ioYPAPSZ3NcvA1pGa6A/hWGo3iJZK1t96mGrfxy2mSFFqGHQbj4ix6D7PpCfVkjuUMp3NG3XjgGhmynK88XENWXBQfgxdfwylZZSQTm058BubkuM5MXgf4WGL3qWo+wWk9AOwjohAGq3UAf5Q341g/OlPGbCV3rBPTnlm866N8aAsHtppg5HwbknaySpLMPcv0KhUGC/bEPgbm3tuG7JZKsoqvDmWr/I+LjVi/LKg=='
18
- my_boolean: 'false'
19
- my_dynamic_setting: 2
20
- another_level:
21
- setting_one: 1
22
- setting_two: 2
23
- level_three:
24
- an_array:
25
- - item 1
26
- - item 2
27
- - item 3
28
- a_scalar: hello
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspectacular'
3
- require 'chamber/commands/files'
4
-
5
- module Chamber
6
- module Commands
7
- describe Files do
8
- let(:rootpath) { ::File.expand_path('./spec/fixtures') }
9
- let(:options) do
10
- {
11
- basepath: rootpath,
12
- rootpath: rootpath,
13
- }
14
- end
15
-
16
- it 'can return values formatted as environment variables' do
17
- files = Files.call(options)
18
-
19
- expect(files.size).to eql 1
20
- expect(files.first).to include 'spec/fixtures/settings.yml'
21
- end
22
- end
23
- end
24
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspectacular'
3
- require 'chamber/commands/heroku/clear'
4
-
5
- module Chamber
6
- module Commands
7
- module Heroku
8
- describe Clear do
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspectacular'
3
- require 'chamber/commands/heroku/compare'
4
-
5
- module Chamber
6
- module Commands
7
- module Heroku
8
- describe Compare do
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspectacular'
3
- require 'chamber/commands/heroku/pull'
4
-
5
- module Chamber
6
- module Commands
7
- module Heroku
8
- describe Pull do
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspectacular'
3
- require 'chamber/commands/heroku/push'
4
-
5
- module Chamber
6
- module Commands
7
- module Heroku
8
- describe Push do
9
- end
10
- end
11
- end
12
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspectacular'
3
- require 'chamber/commands/secure'
4
- require 'fileutils'
5
-
6
- module Chamber
7
- module Commands
8
- describe Secure do
9
- let(:rootpath) { Pathname.new(::File.expand_path('./spec/fixtures')) }
10
- let(:settings_directory) { rootpath + 'settings' }
11
- let(:settings_filename) { settings_directory + 'unencrypted.yml' }
12
- let(:options) do
13
- {
14
- basepath: rootpath,
15
- rootpath: rootpath,
16
- encryption_key: rootpath + '../spec_key',
17
- shell: double.as_null_object,
18
- }
19
- end
20
-
21
- before(:each) do
22
- ::FileUtils.mkdir_p settings_directory unless ::File.exist? settings_directory
23
- end
24
-
25
- after(:each) do
26
- ::FileUtils.rm_rf(settings_directory) if ::File.exist? settings_directory
27
- end
28
-
29
- it 'can return values formatted as environment variables' do
30
- settings_filename.write <<-HEREDOC
31
- test:
32
- _secure_my_unencrpyted_setting: hello
33
- HEREDOC
34
-
35
- Secure.call(options)
36
-
37
- expect(settings_filename.read).
38
- to match %r{_secure_my_unencrpyted_setting: [A-Za-z0-9\+\/]{342}==}
39
- end
40
- end
41
- end
42
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspectacular'
3
- require 'chamber/commands/show'
4
-
5
- module Chamber
6
- module Commands
7
- describe Show do
8
- let(:rootpath) { ::File.expand_path('./spec/fixtures') }
9
- let(:options) do
10
- {
11
- basepath: rootpath,
12
- rootpath: rootpath,
13
- namespaces: 'test',
14
- decryption_key: './spec/spec_key',
15
- }
16
- end
17
-
18
- it 'can return values formatted as environment variables' do
19
- expect(Show.call(options.merge(as_env: true))).to eql(
20
- <<-HEREDOC.chomp
21
- ANOTHER_LEVEL_LEVEL_THREE_A_SCALAR="hello"
22
- ANOTHER_LEVEL_LEVEL_THREE_AN_ARRAY="["item 1", "item 2", "item 3"]"
23
- ANOTHER_LEVEL_SETTING_ONE="1"
24
- ANOTHER_LEVEL_SETTING_TWO="2"
25
- MY_BOOLEAN="false"
26
- MY_DYNAMIC_SETTING="2"
27
- MY_SECURE_SETTINGS="my_secure_value"
28
- MY_SETTING="my_value"
29
- HEREDOC
30
- )
31
- end
32
-
33
- it 'can return values filtered by whether or not they are secure' do
34
- expect(Show.call(options.merge(as_env: true, only_sensitive: true))).to eql(
35
- <<-HEREDOC.chomp
36
- MY_SECURE_SETTINGS="my_secure_value"
37
- HEREDOC
38
- )
39
- end
40
-
41
- it 'can return values formatted as a hash' do
42
- expect(Show.call(options)).to eql(
43
- <<-HEREDOC.chomp
44
- {"my_setting"=>"my_value",
45
- "my_secure_settings"=>"my_secure_value",
46
- "my_boolean"=>false,
47
- "my_dynamic_setting"=>2,
48
- "another_level"=>
49
- {"setting_one"=>1,
50
- "setting_two"=>2,
51
- "level_three"=>
52
- {"an_array"=>["item 1", "item 2", "item 3"],
53
- "a_scalar"=>"hello"}}}
54
- HEREDOC
55
- )
56
- end
57
- end
58
- end
59
- end
@@ -1,164 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspectacular'
3
- require 'chamber/context_resolver'
4
-
5
- module Chamber
6
- module Commands
7
- describe ContextResolver do
8
- let(:rails_2_path) { ::File.expand_path('../../../rails-2-test', __FILE__) }
9
- let(:rails_3_path) { ::File.expand_path('../../../rails-3-test', __FILE__) }
10
- let(:rails_4_path) { ::File.expand_path('../../../rails-4-test', __FILE__) }
11
- let(:rails_engine_path) { ::File.expand_path('../../../rails-engine-test', __FILE__) }
12
-
13
- before(:each) { @old_chamber_key = ENV.delete('CHAMBER_KEY') }
14
- after(:each) { ENV['CHAMBER_KEY'] = @old_chamber_key }
15
-
16
- it 'does not attempt to do any resolution if all valid options are passed in' do
17
- options = ContextResolver.resolve(basepath: 'my_path',
18
- namespaces: 'ns')
19
-
20
- expect(options[:basepath].to_s).to eql 'my_path'
21
- expect(options[:namespaces]).to eql 'ns'
22
- end
23
-
24
- it 'does not attempt to do any resolution if files are passed in in place of a ' \
25
- 'basepath' do
26
-
27
- options = ContextResolver.resolve(files: 'my_files',
28
- namespaces: 'ns')
29
-
30
- expect(options[:files]).to eql 'my_files'
31
- expect(options[:namespaces]).to eql 'ns'
32
- end
33
-
34
- it 'defaults the basepath to the rootpath if none is explicitly set' do
35
- options = ContextResolver.resolve(rootpath: './app',
36
- namespaces: 'ns')
37
-
38
- expect(options[:basepath].to_s).to eql './app'
39
- end
40
-
41
- it 'always sets the basepath to a Pathname even if it is passed in as a String' do
42
- options = ContextResolver.resolve(basepath: './app')
43
-
44
- expect(options[:basepath]).to be_a Pathname
45
- end
46
-
47
- it 'sets the default files if none are passed in' do
48
- options = ContextResolver.resolve(basepath: './app')
49
-
50
- expect(options[:files].map(&:to_s)).to eql [
51
- './app/settings*.yml',
52
- './app/settings',
53
- ]
54
- end
55
-
56
- it 'can handle if keys are passed as strings' do
57
- options = ContextResolver.resolve('files' => 'my_files',
58
- 'namespaces' => 'ns')
59
-
60
- expect(options[:files]).to eql 'my_files'
61
- expect(options[:namespaces]).to eql 'ns'
62
- end
63
-
64
- it 'sets the rootpath to the current working directory if none is passed in' do
65
- allow(Pathname).to receive(:pwd).
66
- and_return('my_dir')
67
-
68
- options = ContextResolver.resolve
69
-
70
- expect(options[:rootpath].to_s).to eql 'my_dir'
71
- end
72
-
73
- it 'sets the encryption key to the default if not passed in' do
74
- options = ContextResolver.resolve(rootpath: rails_3_path)
75
-
76
- expect(options[:encryption_key].to_s).to include 'rails-3-test/.chamber.pub.pem'
77
- end
78
-
79
- it 'sets the decryption key to the default if not passed in' do
80
- options = ContextResolver.resolve(rootpath: rails_3_path)
81
- key_contents = ::File.read(rails_3_path + '/.chamber.pem')
82
-
83
- expect(options[:decryption_key].to_s).to eql key_contents
84
- end
85
-
86
- it 'sets the decryption key to the value of the CHAMBER_KEY if available' do
87
- ENV['CHAMBER_KEY'] = 'my key'
88
-
89
- options = ContextResolver.resolve(rootpath: 'my_path')
90
-
91
- expect(options[:decryption_key].to_s).to eql 'my key'
92
-
93
- ENV['CHAMBER_KEY'] = nil
94
- end
95
-
96
- it 'does not set the encryption key if the keyfile does not exist' do
97
- options = ContextResolver.resolve(rootpath: './app')
98
-
99
- expect(options[:encryption_key]).to be_nil
100
- end
101
-
102
- it 'does not set the decryption key if the keyfile does not exist' do
103
- options = ContextResolver.resolve(rootpath: './app')
104
-
105
- expect(options[:decryption_key]).to be_nil
106
- end
107
-
108
- it 'sets the information to a Rails preset even if it is not pointing to a Rails app' do
109
- options = ContextResolver.resolve(rootpath: './app',
110
- preset: 'rails')
111
-
112
- expect(options[:basepath].to_s).to include './app/config'
113
- expect(options[:namespaces]).to eql []
114
- end
115
-
116
- it 'sets the information to a Rails preset when the rootpath is a Rails app' do
117
- allow(Socket).to receive(:gethostname).and_return 'my_host'
118
-
119
- options = ContextResolver.resolve(rootpath: rails_3_path,
120
- preset: 'rails')
121
-
122
- expect(options[:basepath].to_s).to include 'rails-3-test/config'
123
- expect(options[:namespaces]).to eql %w{development my_host}
124
- end
125
-
126
- it 'sets the basepath if inside a Rails 2 project' do
127
- allow(Socket).to receive(:gethostname).and_return 'my_host'
128
-
129
- options = ContextResolver.resolve(rootpath: rails_2_path)
130
-
131
- expect(options[:basepath].to_s).to include 'rails-2-test/config'
132
- expect(options[:namespaces]).to eql %w{development my_host}
133
- end
134
-
135
- it 'sets the basepath if inside a Rails 3 project' do
136
- allow(Socket).to receive(:gethostname).and_return 'my_host'
137
-
138
- options = ContextResolver.resolve(rootpath: rails_3_path)
139
-
140
- expect(options[:basepath].to_s).to include 'rails-3-test/config'
141
- expect(options[:namespaces]).to eql %w{development my_host}
142
- end
143
-
144
- it 'sets the basepath if inside a Rails 4 project' do
145
- allow(Socket).to receive(:gethostname).and_return 'my_host'
146
-
147
- options = ContextResolver.resolve(rootpath: rails_4_path)
148
-
149
- expect(options[:basepath].to_s).to include 'rails-4-test/config'
150
- expect(options[:namespaces]).to eql %w{development my_host}
151
- end
152
-
153
- it 'sets the basepath if inside a Rails engine' do
154
- allow(Socket).to receive(:gethostname).and_return 'my_host'
155
-
156
- options = ContextResolver.resolve(rootpath: rails_engine_path)
157
-
158
- expect(options[:rootpath].to_s).to include 'rails-engine-test/spec/dummy'
159
- expect(options[:basepath].to_s).to include 'rails-engine-test/spec/dummy/config'
160
- expect(options[:namespaces]).to eql %w{development my_host}
161
- end
162
- end
163
- end
164
- end