forked from postrank-labs/goliath
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv_spec.rb
More file actions
55 lines (45 loc) · 1.26 KB
/
Copy pathenv_spec.rb
File metadata and controls
55 lines (45 loc) · 1.26 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require 'spec_helper'
require 'goliath/env'
describe Goliath::Env do
before(:each) do
@env = Goliath::Env.new
end
it 'responds to []=' do
lambda { @env['test'] = 'blah' }.should_not raise_error
end
it 'responds to []' do
@env['test'] = 'blah'
lambda { @env['test'].should == 'blah' }.should_not raise_error
end
context '#method_missing' do
it 'allows access to items as methods' do
@env['db'] = 'test'
@env.db.should == 'test'
end
it 'allows access to config items as methods' do
@env['config'] = {}
@env['config']['db'] = 'test'
@env.db.should == 'test'
end
end
context '#respond_to?' do
it 'returns true for items in the hash' do
@env['test'] = 'true'
@env.respond_to?(:test).should be_true
end
it 'returns false for items not in hash' do
@env.respond_to?(:test).should be_false
end
it 'returns true for items in the config hash' do
@env['config'] = {'test' => true}
@env.respond_to?(:test).should be_true
end
it 'returns false for items not in the config hash' do
@env['config'] = {}
@env.respond_to?(:test).should be_false
end
it 'delegates if not found' do
@env.respond_to?(:[]).should be_true
end
end
end