Last change
on this file since 30960 was 30960, checked in by davidb, 8 years ago |
Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster
|
-
Property svn:executable
set to
*
|
File size:
1.2 KB
|
Rev | Line | |
---|
[30960] | 1 | require 'spec_helper'
|
---|
| 2 |
|
---|
| 3 | describe 'loadyaml' do
|
---|
| 4 | it { is_expected.not_to eq(nil) }
|
---|
| 5 | it { is_expected.to run.with_params().and_raise_error(ArgumentError, /wrong number of arguments/i) }
|
---|
| 6 |
|
---|
| 7 | context 'when a non-existing file is specified' do
|
---|
| 8 | let(:filename) { '/tmp/doesnotexist' }
|
---|
| 9 | before {
|
---|
| 10 | File.expects(:exists?).with(filename).returns(false).once
|
---|
| 11 | YAML.expects(:load_file).never
|
---|
| 12 | }
|
---|
| 13 | it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) }
|
---|
| 14 | end
|
---|
| 15 |
|
---|
| 16 | context 'when an existing file is specified' do
|
---|
| 17 | let(:filename) { '/tmp/doesexist' }
|
---|
| 18 | let(:data) { { 'key' => 'value' } }
|
---|
| 19 | before {
|
---|
| 20 | File.expects(:exists?).with(filename).returns(true).once
|
---|
| 21 | YAML.expects(:load_file).with(filename).returns(data).once
|
---|
| 22 | }
|
---|
| 23 | it { is_expected.to run.with_params(filename).and_return(data) }
|
---|
| 24 | end
|
---|
| 25 |
|
---|
| 26 | context 'when the file could not be parsed' do
|
---|
| 27 | let(:filename) { '/tmp/doesexist' }
|
---|
| 28 | before {
|
---|
| 29 | File.expects(:exists?).with(filename).returns(true).once
|
---|
| 30 | YAML.stubs(:load_file).with(filename).once.raises StandardError, 'Something terrible have happened!'
|
---|
| 31 | }
|
---|
| 32 | it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) }
|
---|
| 33 | end
|
---|
| 34 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.