fedux_org-stdlib 0.8.8 → 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f506723ed12d859cf1a77d2691967d7cf2ac3320
4
- data.tar.gz: 3863d6a9ddcef3d63f17193fa42f1cfbe66e0656
3
+ metadata.gz: f62d5a27aedacb625f6f8eb5f6aea8ea4d9a35ee
4
+ data.tar.gz: f8a311b2d482357f56fda9685b9607429b59a56f
5
5
  SHA512:
6
- metadata.gz: c2861db382e28f365b9fc89a962efe35156389f462e83366536a82b24f22fe0164b7b84129c439f5ffe55c8f39e70338b90d35b20298286216a44988dd2f4f80
7
- data.tar.gz: ba38b5cec4597945b9e6a40b1161d23c7acd03bd9ee19abb4c5cd79fe36579587af2da78a07515285e809a0ded8224352fab6d09cd643e354fced56fde1693e7
6
+ metadata.gz: 7fbf474910a832397d28f4a1787ca11b9eca0fb99cd72867cb325a1d24e1c983762891d50bfa08d926ba22f3d87d1ab57fcf4976c9046cbc142e8f7d1da603dd
7
+ data.tar.gz: 885cf2b6525b40e84b82ce9caf57ebe39a724b7cdb6ae06b846356baf48711eab2963f1eba6f4ba2879a545678bfbcd23066e5e245daf06c6543b5bfa68f1b8e
data/Gemfile CHANGED
@@ -41,8 +41,8 @@ group :development, :test do
41
41
  gem 'travis-lint'
42
42
  gem 'facter'
43
43
  gem 'hirb'
44
- #gem 'tty'
44
+ # gem 'tty'
45
45
 
46
46
  gem 'fedux_org_stdlib-fixtures-plugin_manager-load', require: false, path: File.expand_path('../fixtures/plugin-load-app', __FILE__)
47
- # gem 'fedux_org_stdlib-fixtures-plugin_manager-no_load', require: false, path: File.expand_path('../fixtures/plugin-no_load-app', __FILE__)
47
+ # gem 'fedux_org_stdlib-fixtures-plugin_manager-no_load', require: false, path: File.expand_path('../fixtures/plugin-no_load-app', __FILE__)
48
48
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fedux_org-stdlib (0.8.7)
4
+ fedux_org-stdlib (0.8.8)
5
5
  activesupport
6
6
 
7
7
  PATH
@@ -259,6 +259,14 @@ module FeduxOrgStdlib
259
259
  _allowed_config_file_paths.first
260
260
  end
261
261
 
262
+ # Return configuration resetted to defaults
263
+ def defaults
264
+ config = self.dup
265
+ config.instance_variable_set :'@__config', {}
266
+
267
+ config
268
+ end
269
+
262
270
  private
263
271
 
264
272
  def detect_file
@@ -296,7 +304,6 @@ module FeduxOrgStdlib
296
304
  end
297
305
  end
298
306
 
299
-
300
307
  # The name of the config file
301
308
  #
302
309
  # @return [String]
@@ -71,9 +71,7 @@ module FeduxOrgStdlib
71
71
  @working_directory = working_directory
72
72
  @directory ||= (directory || _available_directory)
73
73
 
74
- unless directory
75
- logger.debug "No config directory found at #{_allowed_directory_paths.to_list}, therefor I'm going to use an empty config object instead."
76
- end
74
+ logger.debug "No config directory found at #{_allowed_directory_paths.to_list}, therefor I'm going to use an empty config object instead." unless directory
77
75
  end
78
76
 
79
77
  # Return the path to the preferred config file
@@ -72,9 +72,7 @@ module FeduxOrgStdlib
72
72
  @working_directory = working_directory
73
73
  @file ||= (file || _available_config_file)
74
74
 
75
- unless file
76
- logger.debug "No configuration file found at #{_allowed_config_file_paths.to_list}, therefor I'm going to use an empty config object instead."
77
- end
75
+ logger.debug "No configuration file found at #{_allowed_config_file_paths.to_list}, therefor I'm going to use an empty config object instead." unless file
78
76
  end
79
77
 
80
78
  # Return the path to the preferred configuration file
@@ -13,7 +13,7 @@ module FeduxOrgStdlib
13
13
 
14
14
  def initialize(spec:)
15
15
  @name = spec.name
16
- @author = Array(spec.authors).zip(Array(spec.email)).map { |a, e| format( '%s (%s)', a, e) }.to_list
16
+ @author = Array(spec.authors).zip(Array(spec.email)).map { |a, e| format('%s (%s)', a, e) }.to_list
17
17
  @version = spec.version
18
18
  @homagepage = spec.homepage
19
19
  @active = false
@@ -91,15 +91,15 @@ module FeduxOrgStdlib
91
91
 
92
92
  # String representation
93
93
  def to_s
94
- data = plugins.sort.reduce([]) do |a, e|
95
- a << {
94
+ data = plugins.sort.reduce([]) do |a, e|
95
+ a << {
96
96
  name: e.name,
97
97
  version: e.version,
98
98
  author: e.author,
99
99
  homepage: e.homepage,
100
100
  activated: e.active?,
101
- require_file: e.require_file
102
- }
101
+ require_file: e.require_file
102
+ }
103
103
  end
104
104
 
105
105
  List.new(data).to_s(
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'fedux_org_stdlib/require_files'
3
3
  require_library %w( hirb )
4
- #require_library %w( tty )
4
+ # require_library %w( tty )
5
5
 
6
6
  module FeduxOrgStdlib
7
7
  # A list
@@ -27,6 +27,7 @@ module FeduxOrgStdlib
27
27
  @pattern = File.join(path, '*.yml')
28
28
  @detector = detector
29
29
  @detected_locale = detect_locale(overwrite: default_locale)
30
+ @logger = logger
30
31
 
31
32
  I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
32
33
  I18n.load_path = locale_files
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # FeduxOrgStdlib
3
3
  module FeduxOrgStdlib
4
- VERSION = '0.8.8'
4
+ VERSION = '0.8.9'
5
5
  end
@@ -6,31 +6,52 @@ RSpec.describe AppConfig do
6
6
 
7
7
  context 'options' do
8
8
  it 'creates readers and writers' do
9
- with_env 'HOME' => absolute_path('.') do
10
- config_klass = Class.new(AppConfig) do
11
- option :opt1, nil
9
+ config_klass = Class.new(AppConfig) do
10
+ option :opt1, nil
12
11
 
13
- def _class_name
14
- 'TestConfig'
15
- end
12
+ def _class_name
13
+ 'TestConfig'
14
+ end
16
15
 
17
- def _module_name
18
- 'MyApplication'
19
- end
16
+ def _module_name
17
+ 'MyApplication'
20
18
  end
19
+ end
21
20
 
22
- config = config_klass.new
23
- expect(config.opt1).to be_nil
21
+ config = config_klass.new
22
+ expect(config.opt1).to be_nil
24
23
 
25
- config.opt1 = 'blub'
26
- expect(config.opt1).to eq 'blub'
27
- end
24
+ config.opt1 = 'blub'
25
+ expect(config.opt1).to eq 'blub'
28
26
  end
29
27
 
30
28
  it 'creates readers' do
31
- with_env 'HOME' => absolute_path('.') do
32
- config_klass = Class.new(AppConfig) do
33
- option_reader :opt1, nil
29
+ config_klass = Class.new(AppConfig) do
30
+ option_reader :opt1, nil
31
+
32
+ def _class_name
33
+ 'TestConfig'
34
+ end
35
+
36
+ def _module_name
37
+ 'MyApplication'
38
+ end
39
+ end
40
+
41
+ config = config_klass.new
42
+ expect(config.opt1).to be_nil
43
+
44
+ silence :stderr do
45
+ expect do
46
+ config.opt1 = 'blub'
47
+ end.to raise_error NoMethodError
48
+ end
49
+ end
50
+
51
+ it 'checks for reserved key words' do
52
+ expect do
53
+ Class.new(AppConfig) do
54
+ option_reader :_config_file, nil
34
55
 
35
56
  def _class_name
36
57
  'TestConfig'
@@ -40,222 +61,201 @@ RSpec.describe AppConfig do
40
61
  'MyApplication'
41
62
  end
42
63
  end
64
+ end.to raise_error FeduxOrgStdlib::AppConfig::Exceptions::OptionNameForbidden
65
+ end
43
66
 
44
- config = config_klass.new
45
- expect(config.opt1).to be_nil
67
+ it 'output default values' do
68
+ config_klass = Class.new(AppConfig) do
69
+ option_reader :opt1, 'foobar'
46
70
 
47
- silence :stderr do
48
- expect do
49
- config.opt1 = 'blub'
50
- end.to raise_error NoMethodError
71
+ def _class_name
72
+ 'TestConfig'
51
73
  end
52
- end
53
- end
54
74
 
55
- it 'checks for reserved key words' do
56
- with_env 'HOME' => absolute_path('.') do
57
- expect do
58
- Class.new(AppConfig) do
59
- option_reader :_config_file, nil
75
+ def _module_name
76
+ 'MyApplication'
77
+ end
78
+ end
60
79
 
61
- def _class_name
62
- 'TestConfig'
63
- end
80
+ write_file '~/.tests.yaml', <<-EOS.strip_heredoc
81
+ ---
82
+ opt1: hello world
83
+ EOS
64
84
 
65
- def _module_name
66
- 'MyApplication'
67
- end
68
- end
69
- end.to raise_error FeduxOrgStdlib::AppConfig::Exceptions::OptionNameForbidden
70
- end
85
+ config = config_klass.new
86
+ expect(config.defaults.opt1).to eq 'foobar'
87
+ expect(config.opt1).to eq 'hello world'
71
88
  end
72
89
  end
73
90
 
74
91
  context '#lock' do
75
92
  it 'raises error if config is locked and one tries to modify a config option' do
76
- with_env 'HOME' => absolute_path('.') do
77
- config_klass = Class.new(AppConfig) do
78
- option :opt1, nil
79
-
80
- def _class_name
81
- 'TestConfig'
82
- end
93
+ config_klass = Class.new(AppConfig) do
94
+ option :opt1, nil
83
95
 
84
- def _module_name
85
- 'MyApplication'
86
- end
96
+ def _class_name
97
+ 'TestConfig'
87
98
  end
88
99
 
89
- config = config_klass.new
90
- config.lock
91
- expect { config.opt1 = 1 }.to raise_error FeduxOrgStdlib::AppConfig::Exceptions::ConfigLocked
100
+ def _module_name
101
+ 'MyApplication'
102
+ end
92
103
  end
104
+
105
+ config = config_klass.new
106
+ config.lock
107
+ expect { config.opt1 = 1 }.to raise_error FeduxOrgStdlib::AppConfig::Exceptions::ConfigLocked
93
108
  end
94
109
  end
95
110
 
96
111
  context '#preferred_configuration_file' do
97
112
  it 'has a default configuration file which is the preferred place to store the configuration' do
98
- with_env 'HOME' => absolute_path('.') do
99
- config_klass = Class.new(AppConfig) do
100
-
101
- def _class_name
102
- 'TestConfig'
103
- end
113
+ config_klass = Class.new(AppConfig) do
104
114
 
105
- def _module_name
106
- 'MyApplication'
107
- end
115
+ def _class_name
116
+ 'TestConfig'
108
117
  end
109
118
 
110
- config = config_klass.new
111
- expect(config.preferred_configuration_file).to eq File.expand_path('~/.config/my_application/tests.yaml')
119
+ def _module_name
120
+ 'MyApplication'
121
+ end
112
122
  end
123
+
124
+ config = config_klass.new
125
+ expect(config.preferred_configuration_file).to eq File.expand_path('~/.config/my_application/tests.yaml')
113
126
  end
114
127
 
115
128
  it 'works with nested module names' do
116
- with_env 'HOME' => absolute_path('.') do
117
- config_klass = Class.new(AppConfig) do
118
-
119
- def _class_name
120
- 'TestConfig'
121
- end
129
+ config_klass = Class.new(AppConfig) do
122
130
 
123
- def _module_name
124
- 'MyApplication::MySub'
125
- end
131
+ def _class_name
132
+ 'TestConfig'
126
133
  end
127
134
 
128
- config = config_klass.new
129
- expect(config.preferred_configuration_file).to eq File.expand_path('~/.config/my_application/my_sub/tests.yaml')
135
+ def _module_name
136
+ 'MyApplication::MySub'
137
+ end
130
138
  end
139
+
140
+ config = config_klass.new
141
+ expect(config.preferred_configuration_file).to eq File.expand_path('~/.config/my_application/my_sub/tests.yaml')
131
142
  end
132
143
  end
133
144
 
134
145
  context 'config files' do
135
146
 
136
147
  it 'looks at ~/.test.yaml' do
137
- with_env 'HOME' => absolute_path('.') do
138
- write_file '.tests.yaml', <<-EOS.strip_heredoc
148
+ write_file '.tests.yaml', <<-EOS.strip_heredoc
139
149
  ---
140
150
  opt1: hello world
141
- EOS
142
-
143
- config_klass = Class.new(AppConfig) do
144
- option_reader :opt1, nil
151
+ EOS
145
152
 
146
- def _class_name
147
- 'TestConfig'
148
- end
153
+ config_klass = Class.new(AppConfig) do
154
+ option_reader :opt1, nil
149
155
 
150
- def _module_name
151
- 'MyApplication'
152
- end
156
+ def _class_name
157
+ 'TestConfig'
153
158
  end
154
159
 
155
- config = config_klass.new
156
- expect(config.opt1).to eq 'hello world'
160
+ def _module_name
161
+ 'MyApplication'
162
+ end
157
163
  end
164
+
165
+ config = config_klass.new
166
+ expect(config.opt1).to eq 'hello world'
158
167
  end
159
168
 
160
169
  it 'looks at ~/.config/my_application/tests.yaml' do
161
- with_env 'HOME' => absolute_path('.') do
162
- write_file '.config/my_application/tests.yaml', <<-EOS.strip_heredoc
170
+ write_file '.config/my_application/tests.yaml', <<-EOS.strip_heredoc
163
171
  ---
164
172
  opt1: hello world
165
- EOS
166
-
167
- config_klass = Class.new(AppConfig) do
168
- option_reader :opt1, nil
173
+ EOS
169
174
 
170
- def _class_name
171
- 'TestConfig'
172
- end
175
+ config_klass = Class.new(AppConfig) do
176
+ option_reader :opt1, nil
173
177
 
174
- def _module_name
175
- 'MyApplication'
176
- end
178
+ def _class_name
179
+ 'TestConfig'
177
180
  end
178
181
 
179
- config = config_klass.new
180
- expect(config.opt1).to eq 'hello world'
182
+ def _module_name
183
+ 'MyApplication'
184
+ end
181
185
  end
186
+
187
+ config = config_klass.new
188
+ expect(config.opt1).to eq 'hello world'
182
189
  end
183
190
 
184
191
  it 'looks at ~/.my_application/tests.yaml' do
185
- with_env 'HOME' => absolute_path('.') do
186
- write_file '.my_application/tests.yaml', <<-EOS.strip_heredoc
192
+ write_file '.my_application/tests.yaml', <<-EOS.strip_heredoc
187
193
  ---
188
194
  opt1: hello world
189
- EOS
190
-
191
- config_klass = Class.new(AppConfig) do
192
- option_reader :opt1, nil
195
+ EOS
193
196
 
194
- def _class_name
195
- 'TestConfig'
196
- end
197
+ config_klass = Class.new(AppConfig) do
198
+ option_reader :opt1, nil
197
199
 
198
- def _module_name
199
- 'MyApplication'
200
- end
200
+ def _class_name
201
+ 'TestConfig'
201
202
  end
202
203
 
203
- config = config_klass.new
204
- expect(config.opt1).to eq 'hello world'
204
+ def _module_name
205
+ 'MyApplication'
206
+ end
205
207
  end
208
+
209
+ config = config_klass.new
210
+ expect(config.opt1).to eq 'hello world'
206
211
  end
207
212
 
208
213
  it 'looks at ~/.tests.yaml' do
209
- with_env 'HOME' => absolute_path('.') do
210
- write_file '.tests.yaml', <<-EOS.strip_heredoc
214
+ write_file '.tests.yaml', <<-EOS.strip_heredoc
211
215
  ---
212
216
  opt1: hello world
213
- EOS
214
-
215
- config_klass = Class.new(AppConfig) do
216
- option_reader :opt1, nil
217
+ EOS
217
218
 
218
- def _class_name
219
- 'TestConfig'
220
- end
219
+ config_klass = Class.new(AppConfig) do
220
+ option_reader :opt1, nil
221
221
 
222
- def _module_name
223
- 'MyApplication'
224
- end
222
+ def _class_name
223
+ 'TestConfig'
225
224
  end
226
225
 
227
- config = config_klass.new
228
- expect(config.opt1).to eq 'hello world'
226
+ def _module_name
227
+ 'MyApplication'
228
+ end
229
229
  end
230
+
231
+ config = config_klass.new
232
+ expect(config.opt1).to eq 'hello world'
230
233
  end
231
234
 
232
235
  it 'looks at ~/.testsrc' do
233
- with_env 'HOME' => absolute_path('.') do
234
- write_file '.testsrc', <<-EOS.strip_heredoc
236
+ write_file '.testsrc', <<-EOS.strip_heredoc
235
237
  ---
236
238
  opt1: hello world
237
- EOS
238
-
239
- config_klass = Class.new(AppConfig) do
240
- option_reader :opt1, nil
239
+ EOS
241
240
 
242
- def _class_name
243
- 'TestConfig'
244
- end
241
+ config_klass = Class.new(AppConfig) do
242
+ option_reader :opt1, nil
245
243
 
246
- def _module_name
247
- 'MyApplication'
248
- end
244
+ def _class_name
245
+ 'TestConfig'
249
246
  end
250
247
 
251
- config = config_klass.new
252
- expect(config.opt1).to eq 'hello world'
248
+ def _module_name
249
+ 'MyApplication'
250
+ end
253
251
  end
252
+
253
+ config = config_klass.new
254
+ expect(config.opt1).to eq 'hello world'
254
255
  end
255
256
 
256
257
  it 'loads yaml files with the following data types' do
257
- with_env 'HOME' => absolute_path('.') do
258
- write_file '.testsrc', <<-EOS.strip_heredoc
258
+ write_file '.testsrc', <<-EOS.strip_heredoc
259
259
  ---
260
260
  opt1: hello world
261
261
  opt2: :test
@@ -267,131 +267,122 @@ RSpec.describe AppConfig do
267
267
  - b
268
268
  opt7:
269
269
  name: berni
270
- EOS
271
-
272
- config_klass = Class.new(AppConfig) do
273
- option_reader :opt1, nil
274
- option_reader :opt2, nil
275
- option_reader :opt3, nil
276
- option_reader :opt4, nil
277
- option_reader :opt5, nil
278
- option_reader :opt6, nil
279
- option_reader :opt7, nil
270
+ EOS
280
271
 
281
- def _class_name
282
- 'TestConfig'
283
- end
272
+ config_klass = Class.new(AppConfig) do
273
+ option_reader :opt1, nil
274
+ option_reader :opt2, nil
275
+ option_reader :opt3, nil
276
+ option_reader :opt4, nil
277
+ option_reader :opt5, nil
278
+ option_reader :opt6, nil
279
+ option_reader :opt7, nil
284
280
 
285
- def _module_name
286
- 'MyApplication'
287
- end
281
+ def _class_name
282
+ 'TestConfig'
288
283
  end
289
284
 
290
- config = config_klass.new
291
- expect(config.opt1).to eq 'hello world'
285
+ def _module_name
286
+ 'MyApplication'
287
+ end
292
288
  end
289
+
290
+ config = config_klass.new
291
+ expect(config.opt1).to eq 'hello world'
293
292
  end
294
293
 
295
294
  it 'raises error on invalid yaml file' do
296
- with_env 'HOME' => absolute_path('.') do
297
- write_file '.testsrc', random_binary_string(100)
298
-
299
- config_klass = Class.new(AppConfig) do
300
- def _class_name
301
- 'TestConfig'
302
- end
295
+ write_file '.testsrc', random_binary_string(100)
303
296
 
304
- def _module_name
305
- 'MyApplication'
306
- end
297
+ config_klass = Class.new(AppConfig) do
298
+ def _class_name
299
+ 'TestConfig'
307
300
  end
308
301
 
309
- expect { config_klass.new }.to raise_error FeduxOrgStdlib::AppConfig::Exceptions::ConfigFileNotReadable
302
+ def _module_name
303
+ 'MyApplication'
304
+ end
310
305
  end
306
+
307
+ expect { config_klass.new }.to raise_error FeduxOrgStdlib::AppConfig::Exceptions::ConfigFileNotReadable
311
308
  end
312
309
 
313
310
  it 'returns an empty config if data file cannot be transformed to hash' do
314
- with_env 'HOME' => absolute_path('.') do
315
- write_file '.testsrc', <<-EOS.strip_heredoc
311
+ write_file '.testsrc', <<-EOS.strip_heredoc
316
312
  ---
317
313
  - hello
318
314
  - world
319
- EOS
320
-
321
- config_klass = Class.new(AppConfig) do
322
- def _class_name
323
- 'TestConfig'
324
- end
315
+ EOS
325
316
 
326
- def _module_name
327
- 'MyApplication'
328
- end
317
+ config_klass = Class.new(AppConfig) do
318
+ def _class_name
319
+ 'TestConfig'
329
320
  end
330
321
 
331
- result = capture :stderr do
332
- config_klass.new
322
+ def _module_name
323
+ 'MyApplication'
333
324
  end
325
+ end
334
326
 
335
- expect(result).to include 'There seems'
327
+ result = capture :stderr do
328
+ config_klass.new
336
329
  end
330
+
331
+ expect(result).to include 'There seems'
337
332
  end
338
333
  end
339
334
 
340
335
  context '#to_s' do
341
336
  it 'outputs a list of variables' do
342
- with_env 'HOME' => absolute_path('.') do
343
- config_klass = Class.new(AppConfig) do
344
- option :opt1, 'test1'
345
- option :opt2, 'test2'
346
- option :opt3, opt1: 'test1', opt2: 'test2'
337
+ config_klass = Class.new(AppConfig) do
338
+ option :opt1, 'test1'
339
+ option :opt2, 'test2'
340
+ option :opt3, opt1: 'test1', opt2: 'test2'
347
341
 
348
- def _class_name
349
- 'TestConfig'
350
- end
342
+ def _class_name
343
+ 'TestConfig'
344
+ end
351
345
 
352
- def _module_name
353
- 'MyApplication'
354
- end
346
+ def _module_name
347
+ 'MyApplication'
355
348
  end
349
+ end
356
350
 
357
- config = config_klass.new
358
- expect(config.to_s).to eq <<-EOS.strip_heredoc.chomp
351
+ config = config_klass.new
352
+ expect(config.to_s).to eq <<-EOS.strip_heredoc.chomp
359
353
  option | value
360
354
  ------ + --------------------------------------------------------------------------------
361
355
  opt1 | "test1"
362
356
  opt2 | "test2"
363
357
  opt3 | "opt1: test1", "opt2: test2"
364
- EOS
365
- end
358
+ EOS
366
359
  end
367
360
 
368
361
  it 'outputs is undefined for blank values (nil, '', ...)' do
369
- with_env 'HOME' => absolute_path('.') do
370
- config_klass = Class.new(AppConfig) do
371
- option :opt1, nil
372
- option :opt2, ''
373
- option :opt3, 'asdf'
374
- option :opt4, false
362
+ config_klass = Class.new(AppConfig) do
363
+ option :opt1, nil
364
+ option :opt2, ''
365
+ option :opt3, 'asdf'
366
+ option :opt4, false
375
367
 
376
- def _class_name
377
- 'TestConfig'
378
- end
368
+ def _class_name
369
+ 'TestConfig'
370
+ end
379
371
 
380
- def _module_name
381
- 'MyApplication'
382
- end
372
+ def _module_name
373
+ 'MyApplication'
383
374
  end
375
+ end
384
376
 
385
- config = config_klass.new
386
- expect(config.to_s).to eq <<-EOS.strip_heredoc.chomp
377
+ config = config_klass.new
378
+ expect(config.to_s).to eq <<-EOS.strip_heredoc.chomp
387
379
  option | value
388
380
  ------ + --------------------------------------------------------------------------------
389
381
  opt1 | "is undefined"
390
382
  opt2 | "is undefined"
391
383
  opt3 | "asdf"
392
384
  opt4 | "false"
393
- EOS
394
- end
385
+ EOS
395
386
  end
396
387
  end
397
388
 
@@ -445,52 +436,47 @@ RSpec.describe AppConfig do
445
436
  end
446
437
  end
447
438
 
448
- with_env 'HOME' => absolute_path('.') do
449
- write_file 'tests.yaml', <<-EOS.strip_heredoc
439
+ write_file 'tests.yaml', <<-EOS.strip_heredoc
450
440
  ---
451
441
  opt1: test2
452
- EOS
442
+ EOS
453
443
 
454
- config = in_current_dir do
455
- config_klass.new
456
- end
444
+ config = in_current_dir do
445
+ config_klass.new
446
+ end
457
447
 
458
- expect(config.opt1).to eq 'test2'
448
+ expect(config.opt1).to eq 'test2'
459
449
 
460
- write_file '~/.config/my_application/tests.yaml', <<-EOS.strip_heredoc
450
+ write_file '~/.config/my_application/tests.yaml', <<-EOS.strip_heredoc
461
451
  ---
462
452
  opt1: test3
463
- EOS
453
+ EOS
464
454
 
465
- config.redetect
455
+ config.redetect
466
456
 
467
- expect(config.opt1).to eq 'test3'
468
- end
457
+ expect(config.opt1).to eq 'test3'
469
458
  end
470
-
471
459
  end
472
460
 
473
461
  context '#known_options' do
474
462
  it 'outputs a list of known options' do
475
- with_env 'HOME' => absolute_path('.') do
476
- config_klass = Class.new(AppConfig) do
477
- option :opt1, 'test1'
478
- option :opt2, 'test2'
479
- option :opt3, opt1: 'test1', opt2: 'test2'
480
-
481
- def _class_name
482
- 'TestConfig'
483
- end
463
+ config_klass = Class.new(AppConfig) do
464
+ option :opt1, 'test1'
465
+ option :opt2, 'test2'
466
+ option :opt3, opt1: 'test1', opt2: 'test2'
484
467
 
485
- def _module_name
486
- 'MyApplication'
487
- end
468
+ def _class_name
469
+ 'TestConfig'
488
470
  end
489
471
 
490
- config = config_klass.new
491
- expect(config.known_options).to include :opt1, :opt2, :opt3
492
- expect(config.class.known_options).to eq config.known_options
472
+ def _module_name
473
+ 'MyApplication'
474
+ end
493
475
  end
476
+
477
+ config = config_klass.new
478
+ expect(config.known_options).to include :opt1, :opt2, :opt3
479
+ expect(config.class.known_options).to eq config.known_options
494
480
  end
495
481
  end
496
482
  end
@@ -34,12 +34,12 @@ RSpec.describe GemPlugins::PluginManager do
34
34
  expect(result).to include 'plugin-blub'
35
35
  end
36
36
 
37
- #context '#to_s' do
37
+ # context '#to_s' do
38
38
  # it 'has a string representation' do
39
39
  # manager = FeduxOrgStdlib::Fixtures::PluginManager::Load::PluginManager.new
40
40
  # manager.activate_plugin 'fedux_org_stdlib-fixtures-plugin_manager-load'
41
41
 
42
42
  # expect(manager.to_s).to include '1 row in set'
43
43
  # end
44
- #end
44
+ # end
45
45
  end
@@ -44,8 +44,19 @@ end
44
44
 
45
45
  RSpec.configure do |c|
46
46
  c.include FeduxOrgStdlib::SpecHelper::Aruba
47
+
47
48
  c.before :each do
48
49
  clean_current_dir
49
- restore_env
50
50
  end
51
+
52
+ c.around(:example) do |example|
53
+ old_env = ENV.to_h
54
+
55
+ with_env 'HOME' => absolute_path('.') do
56
+ example.run
57
+ end
58
+
59
+ ENV.replace old_env
60
+ end
61
+
51
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fedux_org-stdlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.8.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Meyer