File: env_spec.rb

package info (click to toggle)
ruby-configurate 0.0.8-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 144 kB
  • ctags: 55
  • sloc: ruby: 666; makefile: 5
file content (39 lines) | stat: -rw-r--r-- 1,036 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'spec_helper'

describe Configurate::Provider::Env do
  subject { described_class.new }
  let(:existing_path) { ['existing', 'setting']}
  let(:not_existing_path) { ['not', 'existing', 'path']}
  let(:array_path) { ['array'] }
  before(:all) do
    ENV['EXISTING_SETTING'] = "there"
    ENV['ARRAY'] = "foo,bar,baz"
  end
  
  after(:all) do
    ENV['EXISTING_SETTING'] = nil
    ENV['ARRAY'] = nil
  end
  
  describe '#lookup_path' do
    it "joins and upcases the path" do
      ENV.should_receive(:[]).with("EXISTING_SETTING")
      subject.lookup_path(existing_path)
    end
    
    it "returns nil if the setting isn't available" do
      subject.lookup_path(not_existing_path).should be_nil
    end
    
    it "makes an array out of comma separated values" do
      subject.lookup_path(array_path).should == ["foo", "bar", "baz"]
    end
    
    it "returns a unfrozen string" do
      expect {
        setting = subject.lookup_path(existing_path)
        setting << "foo"
      }.to_not raise_error
    end
  end
end