yaml_properties 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -44,12 +44,12 @@ end
44
44
 
45
45
  #features/support/env.rb
46
46
  After do |scenario|
47
- YamlProperties.reset!
47
+ Shutl.reset!
48
48
  end
49
49
 
50
50
  #features/step_definitions/egg_steps.rb
51
51
  Given /\AThere are \d+ eggs in a dozen\z/ |dozen|
52
- YamlProperties.override_attribute :egg, dozen
52
+ Shutl.override_attribute :egg, dozen
53
53
  end
54
54
  ```
55
55
 
@@ -1,3 +1,3 @@
1
1
  module YamlProperties
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -15,17 +15,25 @@ module YamlProperties
15
15
  end
16
16
 
17
17
  def method_missing(key, *args, &block)
18
- return properties[key] if properties.keys.include? key.to_s
18
+ return properties[key] if key_present? key
19
19
 
20
20
  super key, *args, &block
21
21
  end
22
22
 
23
+
23
24
  def override_attribute attribute, value
25
+ unless key_present? attribute
26
+ raise ArgumentError, "Trying to override non-existent property `#{attribute}' with `#{value}'"
27
+ end
24
28
  properties[attribute] = value
25
29
  end
26
30
 
27
31
  private
28
32
 
33
+ def key_present? key
34
+ properties.keys.include? key.to_s
35
+ end
36
+
29
37
  def yaml_file
30
38
  File.join %w(config properties.yml)
31
39
  end
@@ -26,6 +26,13 @@ describe YamlProperties do
26
26
  YamlProperties.life_the_universe_and_everything.should == 42
27
27
  end
28
28
 
29
+ specify "non-existent attribute overrides shouldn't work" do
30
+ ->{
31
+ YamlProperties.override_attribute :unset_attribute,
32
+ "let's not allow typos to cause us grief"}.
33
+ should raise_error ArgumentError
34
+ end
35
+
29
36
  specify do
30
37
  YamlProperties.properties.should == properties
31
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml_properties
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: