source: src/puppetcode/environments/test/modules/stdlib/spec/functions/loadyaml_spec.rb@ 9baac5a

debian/bullseye debian/jessie
Last change on this file since 9baac5a was 1c22429, checked in by Joachim Langenbach <joachim.langenbach@…>, 10 years ago
  • gnuboat_epd adds the apt repository from gnuboat to install epd-fuse package
  • Property mode set to 100755
File size: 950 bytes
Line 
1require 'spec_helper'
2
3describe 'loadyaml' do
4 it { is_expected.not_to eq(nil) }
5 it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
6 it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
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).and_return(nil) }
14 end
15 context 'when an existing file is specified' do
16 let(:filename) { '/tmp/doesexist' }
17 let(:data) { { 'key' => 'value' } }
18 before {
19 File.expects(:exists?).with(filename).returns(true).once
20 YAML.expects(:load_file).with(filename).returns(data).once
21 }
22 it { is_expected.to run.with_params(filename).and_return(data) }
23 end
24end
Note: See TracBrowser for help on using the repository browser.