has_configuration 0.2.2 → 0.2.3

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: 95d950812e279b6c249386d5daa7f8bf1ea8b610
4
- data.tar.gz: 73a4c8ae615450b07d3d04f1ce19489b272f0870
3
+ metadata.gz: 0b4c87a9c9cdb025d19875a2e5734dbeb790f993
4
+ data.tar.gz: 05bf88f07b04cbbe9aacc63e0e891d27f93b9a7c
5
5
  SHA512:
6
- metadata.gz: 77e674cf3d7418efde319a083aa03ba30b3f729d0e984979caad995f0e0807b45a2136427173f3d01f8921e19c3dc1848d565106230d4b68d0c4ea652c2b505c
7
- data.tar.gz: 502ffce5cf4bd8d5b2a5c7d72b87565a7201b441e2db704057ad8bee97d0938b41f0c8b6eb9a5638a77bd98b56dc801b0a1a553acea098542a0ac39383dc586b
6
+ metadata.gz: a1a3a4f8518d31dbecb814b96d01f3897b7e549604145592abb7da3e3d5c713f6524ab98b1047e50cd19d4995dac421af06635b78a78e8ab45f85b53c20d498a
7
+ data.tar.gz: 006c38eeaa6607b80099db8d71ea8cafc3abd62ab120ecda5a8c7d9fd546583f9ad01f4c9185cccc0815fcd013e0a05dcf7470ab9f3fd524f25b862453a50191
data/lib/version.rb CHANGED
@@ -2,8 +2,8 @@ module HasConfiguration #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- BUILD = 2
5
+ BUILD = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, BUILD].join('.')
8
8
  end
9
- end
9
+ end
@@ -1,5 +1,5 @@
1
- development:
2
- env: development
1
+ test:
2
+ env: test
3
3
 
4
4
  production:
5
5
  env: production
@@ -1,6 +1,6 @@
1
1
  defaults: &defaults
2
2
  default: default
3
3
 
4
- development:
4
+ test:
5
5
  <<: *defaults
6
- development: development
6
+ env: test
@@ -1,2 +1,2 @@
1
- development:
1
+ test:
2
2
  erb: <%= Rails.env %>
@@ -1,5 +1,5 @@
1
- development:
2
- development: development
1
+ test:
2
+ env: test
3
3
  nested:
4
4
  foo: bar
5
5
  baz: true
@@ -1,83 +1,86 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe HasConfiguration::Configuration do
4
-
5
4
  let(:klass) { Class }
6
5
 
7
- describe ".new" do
6
+ before do
7
+ allow_any_instance_of(
8
+ Configuration
9
+ ).to receive(:raw_file).and_return(File.read(fixture))
10
+ end
8
11
 
9
- before { mock_file('spec/fixtures/class.yml') }
12
+ describe ".new" do
13
+ let(:fixture) { 'spec/fixtures/class.yml' }
10
14
 
11
15
  context "when no filename provided" do
12
-
13
16
  let(:file) { "/RAILS_ROOT/config/class.yml" }
14
17
 
15
18
  it "loads default file" do
16
19
  expect_any_instance_of(Configuration).to receive(:raw_file).with(file)
17
20
  HasConfiguration::Configuration.new(klass)
18
21
  end
19
-
20
22
  end
21
23
 
22
24
  context "when filename provided" do
23
-
24
25
  let(:file) { "foo/bar.yml" }
25
26
 
26
27
  it "loads provided file" do
27
28
  expect_any_instance_of(Configuration).to receive(:raw_file).with(file)
28
29
  HasConfiguration::Configuration.new(klass, :file => file)
29
30
  end
30
-
31
31
  end
32
-
33
32
  end
34
33
 
35
34
  context "when initialized" do
35
+ let(:environment) { nil }
36
36
 
37
37
  context "environment" do
38
-
39
- before { mock_file('spec/fixtures/class.yml') }
38
+ let(:fixture) { 'spec/fixtures/class.yml' }
40
39
 
41
40
  context "without env option" do
41
+ subject(:hash) { HasConfiguration::Configuration.new(klass).to_h }
42
42
 
43
- subject { HasConfiguration::Configuration.new(klass) }
44
- its(:to_h) { should eq('env' => 'development') }
45
-
43
+ it 'return the expected hash' do
44
+ expect(hash).to eq('env' => 'test')
45
+ end
46
46
  end
47
47
 
48
48
  context "with env option" do
49
-
50
49
  let(:environment) { 'production' }
51
- subject { HasConfiguration::Configuration.new(klass, :env => environment) }
52
- its(:to_h) { should eq('env' => environment) }
53
50
 
51
+ subject(:hash) { HasConfiguration::Configuration.new(klass, :env => environment).to_h }
52
+
53
+ it 'return the expected hash' do
54
+ expect(hash).to eq('env' => environment)
55
+ end
54
56
  end
55
57
 
56
58
  end
57
59
 
58
60
  context "yaml defaults" do
61
+ let(:fixture) { 'spec/fixtures/with_defaults.yml' }
59
62
 
60
- before { mock_file('spec/fixtures/with_defaults.yml') }
61
-
62
- subject { HasConfiguration::Configuration.new(klass) }
63
- its(:to_h) { should eq('default' => 'default', 'development' => 'development') }
63
+ subject(:hash) { HasConfiguration::Configuration.new(klass).to_h }
64
64
 
65
+ it 'return the expected hash' do
66
+ expect(hash).to eq('default' => 'default', 'env' => 'test')
67
+ end
65
68
  end
66
69
 
67
70
  context "with erb" do
71
+ let(:fixture) { 'spec/fixtures/with_erb.yml' }
68
72
 
69
- before { mock_file('spec/fixtures/with_erb.yml') }
70
-
71
- subject { HasConfiguration::Configuration.new(klass) }
72
- its(:to_h) { should eq('erb' => Rails.env) }
73
+ subject(:hash) { HasConfiguration::Configuration.new(klass).to_h }
73
74
 
75
+ it 'return the expected hash' do
76
+ expect(hash).to eq('erb' => Rails.env)
77
+ end
74
78
  end
75
79
 
76
80
  end
77
81
 
78
82
  describe "#to_h" do
79
-
80
- before { mock_file('spec/fixtures/with_nested_attributes.yml') }
83
+ let(:fixture) { 'spec/fixtures/with_nested_attributes.yml' }
81
84
 
82
85
  context "#to_h" do
83
86
  subject { HasConfiguration::Configuration.new(klass).to_h }
@@ -86,30 +89,26 @@ describe HasConfiguration::Configuration do
86
89
 
87
90
  context "#to_h(:stringify)" do
88
91
  subject { HasConfiguration::Configuration.new(klass).to_h(:stringify) }
89
- it { should eq('development' => 'development', 'nested' => { 'foo' => 'bar', 'baz' => true }) }
92
+ it { should eq('env' => 'test', 'nested' => { 'foo' => 'bar', 'baz' => true }) }
90
93
  end
91
94
 
92
95
  context "#to_h(:symbolized)" do
93
96
  subject { HasConfiguration::Configuration.new(klass).to_h(:symbolized) }
94
- it { should eq(:development => 'development', :nested => { :foo => 'bar', :baz => true }) }
97
+ it { should eq(:env => 'test', :nested => { :foo => 'bar', :baz => true }) }
95
98
  end
96
99
 
97
100
  end
98
101
 
99
102
  describe "struct methods" do
100
-
101
- before { mock_file('spec/fixtures/with_nested_attributes.yml') }
102
-
103
103
  let(:configuration) { HasConfiguration::Configuration.new(klass) }
104
+ let(:fixture) { 'spec/fixtures/with_nested_attributes.yml' }
104
105
 
105
106
  it "is structified" do
106
- expect(configuration.to_h[:development] ).to eql('development')
107
- expect(configuration.development ).to eql('development')
107
+ expect(configuration.to_h[:env] ).to eql('test')
108
+ expect(configuration.env ).to eql('test')
108
109
 
109
110
  expect(configuration.to_h[:nested]['foo'] ).to eql('bar')
110
111
  expect(configuration.nested.foo ).to eql('bar')
111
112
  end
112
-
113
113
  end
114
-
115
114
  end
@@ -11,15 +11,23 @@ describe HasConfiguration do
11
11
  end
12
12
 
13
13
  context "the class" do
14
- subject { Dummy }
14
+ subject(:dummy) { Dummy }
15
+
15
16
  it { should respond_to(:configuration) }
16
- its(:configuration) { should be }
17
+
18
+ it 'returns a configuration' do
19
+ expect(dummy.configuration).to be
20
+ end
17
21
  end
18
22
 
19
23
  context "an instance" do
20
- subject { Dummy.new }
24
+ subject(:dummy) { Dummy.new }
25
+
21
26
  it { should respond_to(:configuration) }
22
- its(:configuration) { should be }
27
+
28
+ it 'returns a configuration' do
29
+ expect(dummy.configuration).to be
30
+ end
23
31
  end
24
32
 
25
33
  end
data/spec/spec_helper.rb CHANGED
@@ -3,27 +3,19 @@ require 'yaml'
3
3
  require 'has_configuration'
4
4
  require 'has_configuration/configuration'
5
5
 
6
- RSpec.configure do |config|
7
- config.mock_with :rspec
8
-
9
- config.expect_with :rspec do |c|
10
- c.syntax = :expect
11
- end
6
+ if RUBY_VERSION >= "1.9"
7
+ require 'coveralls'
8
+ Coveralls.wear!
12
9
  end
13
10
 
14
- def mock_file(filename)
15
- Configuration.any_instance.stub(:raw_file).and_return(File.read(filename))
11
+ RSpec.configure do |config|
12
+ config.mock_with :rspec do |mocks|
13
+ mocks.verify_partial_doubles = true
14
+ end
16
15
  end
17
16
 
18
17
  # Mocks Rails Environment
19
18
  Rails = Class.new do
20
-
21
- def self.root
22
- Pathname.new("/RAILS_ROOT")
23
- end
24
-
25
- def self.env
26
- 'development'
27
- end
28
-
19
+ def self.root; Pathname.new("/RAILS_ROOT"); end
20
+ def self.env ; 'test' ; end
29
21
  end
metadata CHANGED
@@ -1,55 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_configuration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Spickermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-19 00:00:00.000000000 Z
11
+ date: 2014-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.3.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.3.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  description: Loads configuration setting from a yml file and adds a configuation method
@@ -61,8 +75,8 @@ extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
63
77
  - MIT-LICENSE
64
- - lib/has_configuration/configuration.rb
65
78
  - lib/has_configuration.rb
79
+ - lib/has_configuration/configuration.rb
66
80
  - lib/version.rb
67
81
  - spec/fixtures/class.yml
68
82
  - spec/fixtures/with_defaults.yml
@@ -81,19 +95,18 @@ require_paths:
81
95
  - - lib
82
96
  required_ruby_version: !ruby/object:Gem::Requirement
83
97
  requirements:
84
- - - '>='
98
+ - - ">="
85
99
  - !ruby/object:Gem::Version
86
100
  version: '0'
87
101
  required_rubygems_version: !ruby/object:Gem::Requirement
88
102
  requirements:
89
- - - '>='
103
+ - - ">="
90
104
  - !ruby/object:Gem::Version
91
105
  version: '0'
92
106
  requirements: []
93
107
  rubyforge_project:
94
- rubygems_version: 2.0.14
108
+ rubygems_version: 2.2.2
95
109
  signing_key:
96
110
  specification_version: 4
97
111
  summary: Simple configuration handling
98
112
  test_files: []
99
- has_rdoc: