spec/configliere/config_file_spec.rb in configliere-0.4.4 vs spec/configliere/config_file_spec.rb in configliere-0.4.5
- old
+ new
@@ -15,19 +15,19 @@
@fake_file = '{ :my_param: val_from_file }'
end
describe 'successfully' do
it 'with an absolute pathname uses it directly' do
- File.should_receive(:open).with('/fake/path.yaml').and_return(@fake_file)
+ File.should_receive(:open).with(%r{/fake/path.yaml}).and_return(@fake_file)
@config.read '/fake/path.yaml'
end
it 'with a simple filename, references it to the default config dir' do
- File.should_receive(:open).with(Configliere::DEFAULT_CONFIG_DIR + '/file.yaml').and_return(@fake_file)
+ File.should_receive(:open).with(File.join(Configliere::DEFAULT_CONFIG_DIR, 'file.yaml')).and_return(@fake_file)
@config.read 'file.yaml'
end
it 'returns the config object for chaining' do
- File.should_receive(:open).with(Configliere::DEFAULT_CONFIG_DIR + '/file.yaml').and_return(@fake_file)
+ File.should_receive(:open).with(File.join(Configliere::DEFAULT_CONFIG_DIR, 'file.yaml')).and_return(@fake_file)
@config.defaults :also_a_param => true
@config.read('file.yaml').should == { :my_param => 'val_from_file', :also_a_param => true }
end
after do
@config[:my_param].should == 'val_from_file'
@@ -85,11 +85,11 @@
describe 'saves to a config file' do
it 'with an absolute pathname, as given' do
fake_file = StringIO.new('', 'w')
- File.should_receive(:open).with('/fake/path.yaml', 'w').and_yield(fake_file)
+ File.should_receive(:open).with(%r{/fake/path.yaml}, 'w').and_yield(fake_file)
fake_file.should_receive(:<<).with("--- \n:my_param: default_val\n:also_a_param: true\n")
@config.save! '/fake/path.yaml'
end
it 'with a simple pathname, in the default config dir' do
@@ -99,11 +99,11 @@
@config.save! 'file.yaml'
end
it 'and ensures the directory exists' do
fake_file = StringIO.new('', 'w')
- File.stub!(:open).with('/fake/path.yaml', 'w').and_yield(fake_file)
+ File.stub!(:open).with(%r{/fake/path.yaml}, 'w').and_yield(fake_file)
FileUtils.should_receive(:mkdir_p).with('/fake')
@config.save! '/fake/path.yaml'
end
end
@@ -114,7 +114,15 @@
@config.resolve!.should equal(@config)
Configliere::ParamParent.class_eval do def resolve!() self ; end ; end
end
end
-end
+ describe '#validate!' do
+ it 'calls super and returns self' do
+ Configliere::ParamParent.class_eval do def validate!() dummy ; end ; end
+ @config.should_receive(:dummy)
+ @config.validate!.should equal(@config)
+ Configliere::ParamParent.class_eval do def validate!() self ; end ; end
+ end
+ end
+end