config-factory 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/lib/config/factory/environment.rb +6 -1
- data/lib/config/factory/module_info.rb +1 -1
- data/spec/unit/config/factory/environment_spec.rb +17 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d5038da1c70870d65c32c8248c705cfe4e6a039
|
4
|
+
data.tar.gz: 7c2a3b6ff820e82e4b7865fee30ce032d9d34c70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d21a5a42dd50543084d31288f66996624c9c06e851065cd04f8d2c31ef8e4f3a648a84a04e066f315041e23d2346158700b6ed3bfe0f755b71654f7eae0379e3
|
7
|
+
data.tar.gz: f329a4fec0d2a1f26c364a3c9515018ad8fcc9a2dda3541f425162a7aa979061cb5e17491801d47b20928dad3feac3f5b27afafeb4dc4cffb60dcadf07c09a1e
|
data/LICENSE.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2016 The Regents of the University of California
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
6
|
a copy of this software and associated documentation files (the
|
@@ -6,7 +6,7 @@ module Config
|
|
6
6
|
|
7
7
|
def initialize(name:, configs:)
|
8
8
|
self.name = name
|
9
|
-
|
9
|
+
self.configs = configs
|
10
10
|
end
|
11
11
|
|
12
12
|
def args_for(config_name)
|
@@ -30,6 +30,11 @@ module Config
|
|
30
30
|
@name = v
|
31
31
|
end
|
32
32
|
|
33
|
+
def configs=(v)
|
34
|
+
fail ArgumentError, 'Configs must be a hash' unless v && v.respond_to?(:[])
|
35
|
+
@configs = v
|
36
|
+
end
|
37
|
+
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
@@ -22,6 +22,12 @@ module Config
|
|
22
22
|
expect(env.args_for(key)).to eq(yaml_hash[key])
|
23
23
|
end
|
24
24
|
end
|
25
|
+
it 'requires configs' do
|
26
|
+
expect { Environment.new(name: :name, configs: nil) }.to raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
it 'requires configs to be hash-like' do
|
29
|
+
expect { Environment.new(name: :name, configs: false) }.to raise_error(ArgumentError)
|
30
|
+
end
|
25
31
|
end
|
26
32
|
|
27
33
|
describe '#load_file' do
|
@@ -30,6 +36,17 @@ module Config
|
|
30
36
|
expect(env).to be_an(Environment)
|
31
37
|
expect(env.name).to eq(Environments::DEFAULT_ENVIRONMENT)
|
32
38
|
end
|
39
|
+
|
40
|
+
it 'raises an error for malformed files' do
|
41
|
+
bad_yaml = "\t"
|
42
|
+
Dir.mktmpdir do |tmpdir|
|
43
|
+
bad_yaml_path = "#{tmpdir}/config.yml"
|
44
|
+
File.open(bad_yaml_path, 'w') do |f|
|
45
|
+
f.write(bad_yaml)
|
46
|
+
end
|
47
|
+
expect { Environment.load_file(bad_yaml_path) }.to raise_error(Psych::SyntaxError)
|
48
|
+
end
|
49
|
+
end
|
33
50
|
end
|
34
51
|
end
|
35
52
|
end
|