configure_me 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/Guardfile +9 -0
- data/configure_me.gemspec +3 -0
- data/lib/configure_me/attribute_methods.rb +10 -7
- data/lib/configure_me/base.rb +32 -20
- data/lib/configure_me/caching.rb +4 -4
- data/lib/configure_me/loading.rb +2 -2
- data/lib/configure_me/naming.rb +8 -6
- data/lib/configure_me/nesting.rb +35 -29
- data/lib/configure_me/persistence.rb +5 -4
- data/lib/configure_me/persisting.rb +4 -5
- data/lib/configure_me/validations.rb +7 -6
- data/lib/configure_me/version.rb +1 -1
- data/lib/configure_me.rb +1 -6
- data/spec/lib/configure_me/attribute_methods_spec.rb +113 -0
- data/spec/lib/configure_me/base_spec.rb +81 -0
- data/spec/lib/configure_me/caching_spec.rb +75 -0
- data/spec/lib/configure_me/loading_spec.rb +97 -0
- data/spec/lib/configure_me/naming_spec.rb +22 -0
- data/spec/lib/configure_me/nesting_spec.rb +54 -0
- data/spec/lib/configure_me/persistence_spec.rb +65 -0
- data/spec/lib/configure_me/persisting_spec.rb +119 -0
- data/spec/{configure_me → lib/configure_me}/setting_spec.rb +0 -0
- data/spec/spec_helper.rb +3 -1
- metadata +62 -31
- data/lib/configure_me/identity.rb +0 -15
- data/spec/configure_me/attribute_methods_spec.rb +0 -113
- data/spec/configure_me/base_spec.rb +0 -58
- data/spec/configure_me/caching_spec.rb +0 -75
- data/spec/configure_me/identity_spec.rb +0 -30
- data/spec/configure_me/loading_spec.rb +0 -84
- data/spec/configure_me/naming_spec.rb +0 -23
- data/spec/configure_me/nesting_spec.rb +0 -36
- data/spec/configure_me/persistence_spec.rb +0 -62
- data/spec/configure_me/persisting_spec.rb +0 -123
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ConfigureMe do
|
4
|
-
it { should respond_to(:init) }
|
5
|
-
it { should respond_to(:persistence_klass) }
|
6
|
-
it { should respond_to(:cache_object) }
|
7
|
-
it 'should provide nil defaults for :init' do
|
8
|
-
ConfigureMe.init
|
9
|
-
ConfigureMe.persistence_klass.should be_nil
|
10
|
-
ConfigureMe.cache_object.should be_nil
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should accept a hash of initialization arguments' do
|
14
|
-
ConfigureMe.init(:persist_with => 'foo', :cache_with => 'bar')
|
15
|
-
ConfigureMe.persistence_klass.should eql('foo')
|
16
|
-
ConfigureMe.cache_object.should eql('bar')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe ConfigureMe::Base do
|
21
|
-
it 'should enforce the singleton pattern' do
|
22
|
-
lambda { ConfigureMe::Base.new }.should raise_error(NoMethodError)
|
23
|
-
end
|
24
|
-
|
25
|
-
class BaseConfig < ConfigureMe::Base
|
26
|
-
setting :setting1, :type => :integer, :default => 12
|
27
|
-
end
|
28
|
-
|
29
|
-
subject { BaseConfig.instance }
|
30
|
-
its(:persisted?) { should be_true }
|
31
|
-
its(:class) { should respond_to(:setting1) }
|
32
|
-
|
33
|
-
describe 'ActiveModel compliance' do
|
34
|
-
before { @config = define_test_class('TestConfig', ConfigureMe::Base).instance }
|
35
|
-
subject { @config }
|
36
|
-
it_should_behave_like "ActiveModel"
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'find_by_id' do
|
40
|
-
subject { ConfigureMe::Base }
|
41
|
-
before {
|
42
|
-
@mock_config = mock('Config') do
|
43
|
-
stubs(:config_key).returns('the-right-one')
|
44
|
-
stubs(:instance).returns('instance')
|
45
|
-
end
|
46
|
-
@configs = [@mock_config]
|
47
|
-
}
|
48
|
-
it 'should return nil for an invalid id' do
|
49
|
-
subject.stubs(:configs).returns([])
|
50
|
-
subject.find_by_id('something').should be_nil
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should return a matching config' do
|
54
|
-
subject.stubs(:configs).returns(@configs)
|
55
|
-
subject.find_by_id('the-right-one').should eql('instance')
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ConfigureMe::Caching, 'the class' do
|
4
|
-
subject { ConfigureMe::Base }
|
5
|
-
it { should respond_to(:cache_me) }
|
6
|
-
it { should respond_to(:caching?) }
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ConfigureMe::Caching, 'caching?' do
|
10
|
-
before {
|
11
|
-
@caching_class = define_test_class('CachingConfig', ConfigureMe::Base)
|
12
|
-
@caching_class.send(:cache_me)
|
13
|
-
}
|
14
|
-
subject { @caching_class }
|
15
|
-
|
16
|
-
context 'when cache_object is available' do
|
17
|
-
before { ConfigureMe.stubs(:cache_object).returns({}) }
|
18
|
-
specify { subject.caching?.should be_true }
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'when cache_object is unavailable' do
|
22
|
-
before { ConfigureMe.stubs(:cache_object).returns(nil) }
|
23
|
-
specify { subject.caching?.should be_false }
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
describe ConfigureMe::Caching, 'when caching is enabled' do
|
29
|
-
before {
|
30
|
-
@caching_class = define_test_class('CachingConfig', ConfigureMe::Base)
|
31
|
-
@caching_class.stubs(:caching?).returns(true)
|
32
|
-
@cache_object = mock('CacheObject') do
|
33
|
-
stubs(:read).returns('cached_value')
|
34
|
-
stubs(:write)
|
35
|
-
end
|
36
|
-
ConfigureMe.stubs(:cache_object).returns(@cache_object)
|
37
|
-
}
|
38
|
-
subject { @caching_class.instance }
|
39
|
-
|
40
|
-
it 'should attempt to read from the cache' do
|
41
|
-
ConfigureMe.expects(:cache_object).once.returns(@cache_object)
|
42
|
-
subject.read_cache('cachedsetting')
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should return the value from the cache' do
|
46
|
-
subject.read_cache('cachedsetting').should eql('cached_value')
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should attempt to write to the cache' do
|
50
|
-
@cache_object.expects(:write).once
|
51
|
-
subject.write_cache('cachedsetting', 'newvalue')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe ConfigureMe::Caching, 'when caching is disabled' do
|
56
|
-
before {
|
57
|
-
@caching_class = define_test_class('CachingConfig', ConfigureMe::Base)
|
58
|
-
@caching_class.stubs(:caching?).returns(false)
|
59
|
-
}
|
60
|
-
subject { @caching_class.instance }
|
61
|
-
|
62
|
-
it 'should not attempt to read from the cache' do
|
63
|
-
ConfigureMe.expects(:cache_object).never
|
64
|
-
subject.read_cache('cachedsetting')
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'should return nil when read_cache is called' do
|
68
|
-
subject.read_cache('cachedsetting').should be_nil
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'should not attempt to write to the cache' do
|
72
|
-
ConfigureMe.expects(:cache_object).never
|
73
|
-
subject.write_cache('cachedsetting', 'newvalue')
|
74
|
-
end
|
75
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ConfigureMe::Identity do
|
4
|
-
before {
|
5
|
-
@parent_class = define_test_class('ParentConfig', ConfigureMe::Base)
|
6
|
-
@nested_class = define_test_class('NestedConfig', ConfigureMe::Base)
|
7
|
-
}
|
8
|
-
|
9
|
-
context 'a root class' do
|
10
|
-
subject { @parent_class.instance }
|
11
|
-
it { should respond_to(:config_key) }
|
12
|
-
it { should respond_to(:config_name) }
|
13
|
-
it { should respond_to(:storage_key) }
|
14
|
-
its(:config_name) { should eql('parent') }
|
15
|
-
its(:config_key) { should eql('parent') }
|
16
|
-
it 'should generate a valid storage key' do
|
17
|
-
subject.storage_key('foo').should eql('parent-foo')
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'a nested class' do
|
22
|
-
before { @nested_class.send(:nest_me, @parent_class) }
|
23
|
-
subject { @nested_class.instance }
|
24
|
-
its(:config_name) { should eql('nested') }
|
25
|
-
its(:config_key) { should eql('parent-nested') }
|
26
|
-
it 'should generate a valid storage key' do
|
27
|
-
subject.storage_key('foo').should eql('parent-nested-foo')
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ConfigureMe::Loading, 'a filename' do
|
4
|
-
subject { ConfigureMe::Base }
|
5
|
-
it 'should raise an error for a non-existent file' do
|
6
|
-
lambda { subject.load('foo') }.should raise_error(ArgumentError)
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should load an existing file' do
|
10
|
-
File.stubs(:exists?).returns(true)
|
11
|
-
File.stubs(:open).returns({:foo => 'bar'}.to_yaml)
|
12
|
-
subject.expects(:from_hash)
|
13
|
-
subject.load('avalidfile')
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe ConfigureMe::Loading, 'a hash' do
|
18
|
-
subject { ConfigureMe::Base }
|
19
|
-
|
20
|
-
context 'with :app => {:setting1 => \'foo\', :setting2 => 845}' do
|
21
|
-
before { @config = ConfigureMe::Base.load(:app => {:setting1 => 'foo', :setting2 => 845}) }
|
22
|
-
subject { @config.instance }
|
23
|
-
its(:config_name) { should eql('app') }
|
24
|
-
|
25
|
-
it { should respond_to(:setting1) }
|
26
|
-
it { should respond_to(:setting2) }
|
27
|
-
it { should_not respond_to(:setting3) }
|
28
|
-
its(:setting1) { should eql('foo') }
|
29
|
-
its(:setting2) { should eql(845) }
|
30
|
-
its(:parent_config) { should be_nil }
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'with :group1 => {:setting1 => 6, :setting2 => \'foo\'}, :group2 => {:setting3 => 8, :setting4 => \'bar\'}' do
|
34
|
-
describe 'the instance' do
|
35
|
-
before {
|
36
|
-
@config = ConfigureMe::Base.load(
|
37
|
-
:group1 => {
|
38
|
-
:setting1 => 6,
|
39
|
-
:setting2 => 'foo'
|
40
|
-
},
|
41
|
-
:group2 => {
|
42
|
-
:setting3 => 8,
|
43
|
-
:setting4 => 'bar'
|
44
|
-
}
|
45
|
-
)
|
46
|
-
}
|
47
|
-
|
48
|
-
subject { @config.instance }
|
49
|
-
its(:config_name) { should eql('root') }
|
50
|
-
it { should respond_to(:group1) }
|
51
|
-
it { should respond_to(:group2) }
|
52
|
-
it { should_not respond_to(:group3) }
|
53
|
-
|
54
|
-
describe 'group1' do
|
55
|
-
subject { @config.group1 }
|
56
|
-
it { should_not be_nil }
|
57
|
-
it { should respond_to(:setting1) }
|
58
|
-
it { should respond_to(:setting2) }
|
59
|
-
it { should_not respond_to(:setting3) }
|
60
|
-
its(:setting1) { should eql(6) }
|
61
|
-
its(:setting2) { should eql('foo') }
|
62
|
-
its(:parent_config) { should eql(@config.instance) }
|
63
|
-
end
|
64
|
-
|
65
|
-
describe 'group2' do
|
66
|
-
subject { @config.instance.group2 }
|
67
|
-
it { should_not be_nil }
|
68
|
-
it { should respond_to(:setting3) }
|
69
|
-
it { should respond_to(:setting4) }
|
70
|
-
it { should_not respond_to(:setting1) }
|
71
|
-
its(:setting3) { should eql(8) }
|
72
|
-
its(:setting4) { should eql('bar') }
|
73
|
-
its(:parent_config) { should eql(@config.instance) }
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe ConfigureMe::Loading, 'something unsupported' do
|
80
|
-
subject { ConfigureMe::Base }
|
81
|
-
it 'should raise an exception' do
|
82
|
-
lambda { subject.load(123) }.should raise_error(ArgumentError)
|
83
|
-
end
|
84
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ConfigureMe::Naming do
|
4
|
-
class NamingConfig < ConfigureMe::Base
|
5
|
-
end
|
6
|
-
|
7
|
-
before {
|
8
|
-
@persistence_klass = mock('PersistenceKlass') do
|
9
|
-
stubs(:model_name).returns('persistence')
|
10
|
-
end
|
11
|
-
ConfigureMe.stubs(:persistence_klass).returns(@persistence_klass)
|
12
|
-
}
|
13
|
-
subject { NamingConfig }
|
14
|
-
context 'when persisting' do
|
15
|
-
before { NamingConfig.stubs(:persisting?).returns(true) }
|
16
|
-
its(:model_name) { should eql('persistence') }
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'when not persisting' do
|
20
|
-
before { NamingConfig.stubs(:persisting?).returns(false) }
|
21
|
-
its(:model_name) { should_not eql('persistence') }
|
22
|
-
end
|
23
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ConfigureMe::Nesting, 'the class' do
|
4
|
-
subject { ConfigureMe::Base }
|
5
|
-
it { should respond_to(:nest_me) }
|
6
|
-
end
|
7
|
-
|
8
|
-
describe ConfigureMe::Nesting do
|
9
|
-
before {
|
10
|
-
@parent_class = define_test_class('ParentConfig', ConfigureMe::Base)
|
11
|
-
@nested_class = define_test_class('NestedConfig', ConfigureMe::Base)
|
12
|
-
@parent_config = @parent_class.instance
|
13
|
-
@nested_config = @nested_class.instance
|
14
|
-
@parent_class.stubs(:instance).returns(@parent_config)
|
15
|
-
@nested_class.stubs(:instance).returns(@nested_config)
|
16
|
-
@nested_class.send(:nest_me, @parent_class)
|
17
|
-
}
|
18
|
-
|
19
|
-
context 'a nested class' do
|
20
|
-
subject { @nested_config }
|
21
|
-
its(:children) { should be_empty }
|
22
|
-
its(:all_configs) { should have(1).items }
|
23
|
-
its(:parent_config) { should eql(@parent_config) }
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'a parent class' do
|
27
|
-
subject { @parent_config }
|
28
|
-
its(:children) { should have(1).items }
|
29
|
-
its(:children) { should eql(:nested => @nested_config) }
|
30
|
-
its(:all_configs) { should have(2).items }
|
31
|
-
its(:parent_config) { should be_nil }
|
32
|
-
it { should respond_to(:nested) }
|
33
|
-
its(:nested) { should eql(@nested_config) }
|
34
|
-
its(:class) { should respond_to(:nested) }
|
35
|
-
end
|
36
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ConfigureMe::Persistence do
|
4
|
-
before {
|
5
|
-
@persistence_class = define_test_class('PersistenceConfig', ConfigureMe::Base)
|
6
|
-
@config = @persistence_class.instance
|
7
|
-
}
|
8
|
-
subject { @config }
|
9
|
-
describe 'saving' do
|
10
|
-
before {
|
11
|
-
@config.stubs(:write_persist)
|
12
|
-
@config.stubs(:write_cache)
|
13
|
-
@config.stubs(:make_clean)
|
14
|
-
@temp_attrs = {:testsetting => 'newvalue'}
|
15
|
-
@config.stubs(:temp_attributes).returns(@temp_attrs)
|
16
|
-
@config.stubs(:persist_guard).yields
|
17
|
-
}
|
18
|
-
it 'should run callbacks' do
|
19
|
-
@config.expects(:run_callbacks).at_least_once.yields
|
20
|
-
@config.save
|
21
|
-
end
|
22
|
-
it 'should not run the validations if :validate => false is passed' do
|
23
|
-
@config.expects(:valid?).never
|
24
|
-
@config.save(:validate => false)
|
25
|
-
end
|
26
|
-
it 'should start a transaction' do
|
27
|
-
@config.expects(:persist_guard)
|
28
|
-
@config.save
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should persist the temp settings' do
|
32
|
-
@config.expects(:write_persist).with(:testsetting, 'newvalue')
|
33
|
-
@config.save
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should cache the temp settings' do
|
37
|
-
@config.expects(:write_cache).with(:testsetting, 'newvalue')
|
38
|
-
@config.save
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'should clear the dirty status' do
|
42
|
-
@config.expects(:make_clean)
|
43
|
-
@config.save
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'update_attributes' do
|
48
|
-
before {
|
49
|
-
@config.stubs(:write_attribute)
|
50
|
-
}
|
51
|
-
it 'should store the new attributes' do
|
52
|
-
@config.stubs(:save)
|
53
|
-
@config.expects(:write_attribute).with(:testsetting, 'updatedvalue')
|
54
|
-
@config.update_attributes(:testsetting => 'updatedvalue')
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should attempt to save' do
|
58
|
-
@config.expects(:save)
|
59
|
-
@config.update_attributes(:testsetting => 'updatedvalue')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,123 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ConfigureMe::Persisting, 'the class' do
|
4
|
-
subject { ConfigureMe::Base }
|
5
|
-
it { should respond_to(:persist_me) }
|
6
|
-
it { should respond_to(:persisting?) }
|
7
|
-
|
8
|
-
context 'when the persistence_klass is nil' do
|
9
|
-
before {
|
10
|
-
@persisting_klass = define_test_class('PersistingConfig', ConfigureMe::Base)
|
11
|
-
@persisting_klass.send(:persist_me)
|
12
|
-
ConfigureMe.stubs(:persistence_klass).returns(nil)
|
13
|
-
}
|
14
|
-
subject { @persisting_klass }
|
15
|
-
its(:persisting?) { should be_false }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'persist_guard' do
|
19
|
-
before {
|
20
|
-
@persisting_klass = define_test_class('PersistingConfig', ConfigureMe::Base)
|
21
|
-
}
|
22
|
-
subject { @persisting_klass.instance }
|
23
|
-
context 'when transactions are supported' do
|
24
|
-
it 'should begin a transaction' do
|
25
|
-
@transaction_class = mock('TransactionClass') do
|
26
|
-
stubs(:transaction)
|
27
|
-
end
|
28
|
-
ConfigureMe.stubs(:persistence_klass).returns(@transaction_class)
|
29
|
-
@transaction_class.expects(:transaction)
|
30
|
-
subject.persist_guard
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when persisting with something else' do
|
35
|
-
it 'should just execute the block' do
|
36
|
-
@non_transaction_class = mock('NonTransactionClass')
|
37
|
-
ConfigureMe.stubs(:persistence_klass).returns(@non_transaction_class)
|
38
|
-
@testvalue = 'default'
|
39
|
-
subject.persist_guard do
|
40
|
-
@testvalue = 'changed'
|
41
|
-
end
|
42
|
-
@testvalue.should eql('changed')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe ConfigureMe::Persisting, 'when persisting is enabled' do
|
49
|
-
before {
|
50
|
-
@persisting_class = define_test_class('PersistingConfig', ConfigureMe::Base)
|
51
|
-
@persisted_setting = mock('PersistedSetting') do
|
52
|
-
stubs(:value).returns('foo'.to_yaml)
|
53
|
-
stubs(:value=)
|
54
|
-
stubs(:save!)
|
55
|
-
end
|
56
|
-
@persistence_klass = mock('PersistenceKlass')
|
57
|
-
@persistence_klass.stubs(:find_or_create_by_key).returns(@persisted_setting)
|
58
|
-
@persistence_klass.stubs(:find_by_key).returns(@persisted_setting)
|
59
|
-
ConfigureMe.stubs(:persistence_klass).returns(@persistence_klass)
|
60
|
-
@persisting_class.send(:persist_me)
|
61
|
-
}
|
62
|
-
subject { @persisting_class.instance }
|
63
|
-
|
64
|
-
describe 'read_persist' do
|
65
|
-
it 'should read from the persistence store' do
|
66
|
-
@persistence_klass.expects(:find_by_key).once.returns(@persisted_setting)
|
67
|
-
subject.read_persist('persistedsetting')
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'with a persisted value' do
|
71
|
-
it 'should return the converted value' do
|
72
|
-
subject.read_persist('persistedsetting').should eql('foo')
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'with a non-persisted value' do
|
77
|
-
it 'should return nil' do
|
78
|
-
@persistence_klass.stubs(:find_by_key).returns(nil)
|
79
|
-
subject.read_persist('persistedsetting').should be_nil
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe 'write_persist' do
|
85
|
-
it 'should retrieve or create the setting' do
|
86
|
-
@persistence_klass.expects(:find_or_create_by_key).once.returns(@persisted_setting)
|
87
|
-
subject.write_persist('persistedsetting', 'newvalue')
|
88
|
-
end
|
89
|
-
it 'should update the value' do
|
90
|
-
@persisted_setting.expects(:value=).with('newvalue'.to_yaml)
|
91
|
-
subject.write_persist('persistedsetting', 'newvalue')
|
92
|
-
end
|
93
|
-
it 'should save the record' do
|
94
|
-
@persisted_setting.expects(:save!)
|
95
|
-
subject.write_persist('persistedsetting', 'newvalue')
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe ConfigureMe::Persisting, 'when persisting is disabled' do
|
101
|
-
before {
|
102
|
-
@persisting_class = define_test_class('PersistingConfig', ConfigureMe::Base)
|
103
|
-
@persisting_class.stubs(:persisting?).returns(false)
|
104
|
-
}
|
105
|
-
subject { @persisting_class.instance }
|
106
|
-
|
107
|
-
describe 'read_persist' do
|
108
|
-
it 'should not attempt to read from the persistence store' do
|
109
|
-
ConfigureMe.expects(:persistence_klass).never
|
110
|
-
subject.read_persist('persistedsetting')
|
111
|
-
end
|
112
|
-
it 'should return nil' do
|
113
|
-
subject.read_persist('persistedsetting').should be_nil
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe 'write_persist' do
|
118
|
-
it 'should not attempt to write to the persistence store' do
|
119
|
-
ConfigureMe.expects(:persistence_klass).never
|
120
|
-
subject.write_persist('persistedsetting', 'newvalue')
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|