-
Notifications
You must be signed in to change notification settings - Fork 63
/
configurable_spec.rb
56 lines (44 loc) · 1.17 KB
/
configurable_spec.rb
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
56
require File.dirname(__FILE__) + '/spec_helper'
class FooConfig
include DaemonKit::Configurable
configurable :has_default, true
configurable :no_default
configurable :has_lock, :locked => true
end
describe DaemonKit::Configurable do
before(:each) do
@foo = FooConfig.new
end
it "should support default values" do
lambda {
@foo.has_default.should be_true
}.should_not raise_error( NoMethodError )
end
it "should support overwriting unlocked defaults" do
lambda {
@foo.has_default = false
@foo.has_default.should be false
}.should_not raise_error
end
it "should support no default values" do
lambda {
@foo.no_default.should be_nil
}.should_not raise_error( NoMethodError )
end
it "should allow setting locked values once" do
lambda {
@foo.has_lock = 1
@foo.has_lock.should == 1
@foo.has_lock = 2
@foo.has_lock.should == 1
}.should_not raise_error
end
it "should allow bypassing the lock explicitly" do
lambda {
@foo.has_lock = 1
@foo.has_lock.should == 1
@foo.set(:has_lock, 2)
@foo.has_lock.should == 2
}.should_not raise_error
end
end