a9n 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/a9n.rb CHANGED
@@ -15,6 +15,10 @@ module A9n
15
15
  raise ConfigurationNotLoaded.new("Configuration does not seem to be loaded. Plase call A9n.load.")
16
16
  end
17
17
 
18
+ def env
19
+ @@env ||= ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['APP_ENV']
20
+ end
21
+
18
22
  def local_app
19
23
  @@local_app ||= Rails
20
24
  end
@@ -41,7 +45,7 @@ module A9n
41
45
  def load_yml(file)
42
46
  path = File.join(local_app.root, file)
43
47
  return unless File.exists?(path)
44
- YAML.load_file(path)[local_app.env]
48
+ YAML.load_file(path)[self.env]
45
49
  end
46
50
 
47
51
  private
@@ -1,3 +1,3 @@
1
1
  module A9n
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -102,18 +102,22 @@ describe A9n do
102
102
  subject { described_class.load_yml(file_path) }
103
103
 
104
104
  before do
105
- described_class.should_receive(:local_app).at_least(:once).and_return(stub(:env => 'test', :root => root))
105
+ described_class.should_receive(:local_app).at_least(:once).and_return(stub(:root => root))
106
106
  end
107
107
 
108
108
  context 'when file not exists' do
109
+ before { described_class.should_receive(:env).never }
109
110
  let(:file_path) { 'file_not_existing_in_universe.yml' }
111
+
110
112
  it 'returns nil' do
111
113
  subject.should be_nil
112
114
  end
113
115
  end
114
116
 
115
117
  context 'when file exists' do
118
+ before { described_class.should_receive(:env).and_return('test') }
116
119
  let(:file_path) { 'fixtures/configuration.yml'}
120
+
117
121
  it 'returns non-empty hash' do
118
122
  subject.should be_kind_of(Hash)
119
123
  subject.keys.should_not be_empty
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: a9n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: