spec/config_spec.rb in sanultari-config-0.2.0 vs spec/config_spec.rb in sanultari-config-0.2.1
- old
+ new
@@ -1,15 +1,21 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'tempfile'
+require 'fileutils'
describe "SanUltari::Config" do
before :all do
@origin = Dir.getwd
Dir.chdir File.expand_path('../fixture', File.dirname(__FILE__))
end
before :each do
+ @backup = File.expand_path 'fixture.bak', File.dirname(Dir.getwd)
+ FileUtils.cp_r Dir.getwd, @backup
+ end
+
+ before :each do
@fixture = SanUltari::Config.new
end
it "should not have properties" do
expected = 'test'
@@ -18,11 +24,11 @@
@fixture.class.instance_methods.should_not include :a
end
it "should create object without yaml file" do
@fixture.init!
- @fixture.name.should be_nil
+ @fixture.name.should eql 'config'
@fixture.path.should eql File.expand_path('.')
end
it "should create object with yaml file" do
@fixture.init! 'config.yml'
@@ -57,9 +63,25 @@
dump.should eql origin
end
end
tmp_file.unlink
+ end
+
+ it "should load default" do
+ config = SanUltari::Config.new
+ config.test = 'a'
+ config.test2 = 'b'
+ config.a.alpha = 'omega'
+ @fixture.init! '/tmp/default.yml', config
+ end
+
+ after :each do
+ temp = Dir.getwd
+ Dir.chdir '..'
+ FileUtils.cp_r Dir["#{@backup}/*"], temp, remove_destination: true
+ FileUtils.rmtree @backup
+ Dir.chdir temp
end
after :all do
Dir.chdir @origin
end