nifty_settings 1.1.0 → 1.1.1

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: c3f19a22952b832a051d656d2180fa939da773dd
4
- data.tar.gz: f8c9c494f8b908efcb17597444cc4ffccf62da15
3
+ metadata.gz: 6651dcfe4c7f6e0c28276f172219dc97e5ab1651
4
+ data.tar.gz: 632811ea407d4a49ec3202db60b7a5524909ec3f
5
5
  SHA512:
6
- metadata.gz: 3d3e5f5bf289e146b78804d4cb939c650f68c1d89de1b7d7da273f0ef49a5bc728cec6716a14bdad9b9b73838bd79ec74d412925db1389b855232a9140b5cbca
7
- data.tar.gz: 37fcb9282e70ff784af7d76a74d5cbb094410f6159dd7158127ae2ef833031373c0057da2aadb9074a5db3826ad919c2abda4d09dcd7b6aeac01045db907c57a
6
+ metadata.gz: e7592769ffcce4853ebeea1bd67ce70d63672c4baafc39d9204a9a22ff97c178d1c70bc0f94b58e49228244c681892fe7311f109d943f350b9465610c7bff3a7
7
+ data.tar.gz: 8c34282af452aa6462d5f85815eb3701ae347782124fe2152256ad7359ddb221f6c6108552c89e02416a18b3531fc02348e3e70415319d26b1c23a7432071012
@@ -9,6 +9,10 @@ module NiftySettings
9
9
  hash.each_pair { |k, v| self[k] = v }
10
10
  end
11
11
 
12
+ def ==(other)
13
+ self.to_hash == other.to_hash
14
+ end
15
+
12
16
  def to_hash
13
17
  unpack_attr @hash
14
18
  end
@@ -36,8 +40,7 @@ module NiftySettings
36
40
  end
37
41
 
38
42
  def has?(key)
39
- key = key.to_sym
40
- @hash.has_key?(key) && @hash[key].present?
43
+ @hash.has_key?(key.to_sym)
41
44
  end
42
45
 
43
46
  def fetch(key, default = nil)
@@ -1,3 +1,3 @@
1
1
  module NiftySettings
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -1,22 +1,36 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NiftySettings::Settings do
4
- let(:settings_hash) { { foo: 'bar' } }
5
- let(:settings) { NiftySettings::Settings.new(settings_hash) }
6
- let(:empty_settings) { NiftySettings::Settings.new }
4
+ let(:nested_settings_hash) { { pelle: 'fant', shnoo: 'shnaa' } }
5
+ let(:settings_hash) { { foo: 'bar', nested: nested_settings_hash } }
6
+ let(:settings) { NiftySettings::Settings.new(settings_hash) }
7
+ let(:empty_settings) { NiftySettings::Settings.new }
7
8
 
8
- context 'accessing a setting' do
9
- context "when it's not present" do
9
+ context 'comparing two settings' do
10
+ it 'uses the hash to determine whether they are the same' do
11
+ expect(NiftySettings::Settings.new(settings_hash)).to eq(NiftySettings::Settings.new(settings_hash))
12
+ expect(NiftySettings::Settings.new(settings_hash)).to_not eq(NiftySettings::Settings.new(nested_settings_hash))
13
+ end
14
+ end
15
+
16
+ context '#key' do
17
+ context 'when no setting with that key exists' do
10
18
  it 'returns nil' do
11
19
  expect(settings.not_found).to be_nil
12
20
  end
13
21
  end
14
22
 
15
- context "when it's present" do
16
- it 'returns the setting' do
23
+ context 'when the settings has a single value' do
24
+ it 'returns the value' do
17
25
  expect(settings.foo).to eq('bar')
18
26
  end
19
27
  end
28
+
29
+ context 'when the setting has nested values' do
30
+ it 'returns a settings object with the values' do
31
+ expect(settings.nested).to eq(NiftySettings::Settings.new(nested_settings_hash))
32
+ end
33
+ end
20
34
  end
21
35
 
22
36
  describe '#to_s' do
@@ -32,4 +46,24 @@ describe NiftySettings::Settings do
32
46
  end
33
47
  end
34
48
  end
49
+
50
+ describe '#key?' do
51
+ context 'when no setting with that key exists' do
52
+ it 'returns false' do
53
+ expect(settings.bar?).to eq(false)
54
+ end
55
+ end
56
+
57
+ context 'when the settings has a single value' do
58
+ it 'returns true' do
59
+ expect(settings.foo?).to eq(true)
60
+ end
61
+ end
62
+
63
+ context 'when the setting has nested values' do
64
+ it 'returns true' do
65
+ expect(settings.nested?).to eq(true)
66
+ end
67
+ end
68
+ end
35
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nifty_settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Meurer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-23 00:00:00.000000000 Z
11
+ date: 2014-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake