|
10 | 10 | let(:filename) { '/tmp/doesnotexist' } |
11 | 11 |
|
12 | 12 | it "'default' => 'value'" do |
13 | | - expect(File).to receive(:exists?).with(filename).and_return(false).once |
| 13 | + allow(File).to receive(:exist?).and_call_original |
| 14 | + expect(File).to receive(:exist?).with(filename).and_return(false).once |
14 | 15 | expect(YAML).not_to receive(:load_file) |
15 | 16 | expect(subject).to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') |
16 | 17 | end |
|
21 | 22 | let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } } |
22 | 23 |
|
23 | 24 | it "returns 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'" do |
24 | | - expect(File).to receive(:exists?).with(filename).and_return(true).once |
| 25 | + allow(File).to receive(:exist?).and_call_original |
| 26 | + expect(File).to receive(:exist?).with(filename).and_return(true).once |
25 | 27 | expect(YAML).to receive(:load_file).with(filename).and_return(data).once |
26 | 28 | expect(subject).to run.with_params(filename).and_return(data) |
27 | 29 | end |
|
31 | 33 | let(:filename) { '/tmp/doesexist' } |
32 | 34 |
|
33 | 35 | it 'filename /tmp/doesexist' do |
34 | | - expect(File).to receive(:exists?).with(filename).and_return(true).once |
| 36 | + allow(File).to receive(:exist?).and_call_original |
| 37 | + expect(File).to receive(:exist?).with(filename).and_return(true).once |
35 | 38 | allow(YAML).to receive(:load_file).with(filename).once.and_raise(StandardError, 'Something terrible have happened!') |
36 | 39 | expect(subject).to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') |
37 | 40 | end |
|
0 commit comments