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) }
7 context 'when a non-existing file is specified' do
8 let(:filename) { '/tmp/doesnotexist' }
10 File.expects(:exists?).with(filename).returns(false).once
11 YAML.expects(:load_file).never
13 it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) }
14 it { is_expected.to run.with_params(filename, {'đẽƒằưļŧ' => '٧ẵłựέ'}).and_return({'đẽƒằưļŧ' => '٧ẵłựέ'}) }
15 it { is_expected.to run.with_params(filename, {'デフォルト' => '値'}).and_return({'デフォルト' => '値'}) }
18 context 'when an existing file is specified' do
19 let(:filename) { '/tmp/doesexist' }
20 let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'} }
22 File.expects(:exists?).with(filename).returns(true).once
23 YAML.expects(:load_file).with(filename).returns(data).once
25 it { is_expected.to run.with_params(filename).and_return(data) }
28 context 'when the file could not be parsed' do
29 let(:filename) { '/tmp/doesexist' }
31 File.expects(:exists?).with(filename).returns(true).once
32 YAML.stubs(:load_file).with(filename).once.raises StandardError, 'Something terrible have happened!'
34 it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) }