spec/isomer/sources/yaml_spec.rb in isomer-0.1.1 vs spec/isomer/sources/yaml_spec.rb in isomer-0.1.2

- old
+ new

@@ -23,10 +23,20 @@ source.load source.configuration.should == {'foo' => 'bar'} end + it 'returns an empty hash if the content is nil' do + File.stub(:exists?).and_return(true) + YAML.stub(:load_file).and_return(nil) + + source = Isomer::Sources::Yaml.new(anything, file: 'anything.yml') + source.load + + source.configuration.should == {} + end + context 'when the file does not exist' do context 'when it is not required' do it 'does not blow up' do source = Isomer::Sources::Yaml.new(anything, file: '/home/configuration.yml') expect { source.load }.to_not raise_error @@ -56,9 +66,19 @@ source = Isomer::Sources::Yaml.new(anything, file: 'filish.yml', base: 'production') source.load source.configuration.should == {'limit' => 100} + end + + it 'returns an empty hash if the content is nil' do + File.stub(:exists?).and_return(true) + YAML.stub(:load_file).and_return( 'production' => nil ) + + source = Isomer::Sources::Yaml.new(anything, file: 'filish.yml', base: 'production') + source.load + + source.configuration.should == {} end end end end