File tree 2 files changed +6
-0
lines changed
2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change 26
26
end
27
27
28
28
before ( :each ) do
29
+ allow ( File ) . to receive ( :exist? ) . and_call_original
29
30
allow ( File ) . to receive ( :exist? ) . with ( filename ) . and_return ( false ) . once
30
31
if Puppet ::PUPPETVERSION [ 0 ] . to_i < 8
31
32
allow ( PSON ) . to receive ( :load ) . never # rubocop:disable RSpec/ReceiveNever Switching to not_to receive breaks testing in this case
51
52
let ( :json ) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' }
52
53
53
54
before ( :each ) do
55
+ allow ( File ) . to receive ( :exist? ) . and_call_original
54
56
allow ( File ) . to receive ( :exist? ) . with ( filename ) . and_return ( true ) . once
55
57
allow ( File ) . to receive ( :read ) . with ( filename ) . and_return ( json ) . once
56
58
allow ( File ) . to receive ( :read ) . with ( filename ) . and_return ( json ) . once
75
77
let ( :json ) { '{"key":"value"}' }
76
78
77
79
before ( :each ) do
80
+ allow ( File ) . to receive ( :exist? ) . and_call_original
78
81
allow ( File ) . to receive ( :exist? ) . with ( filename ) . and_return ( true ) . once
79
82
allow ( File ) . to receive ( :read ) . with ( filename ) . and_return ( json ) . once
80
83
if Puppet ::PUPPETVERSION [ 0 ] . to_i < 8
Original file line number Diff line number Diff line change 10
10
let ( :filename ) { '/tmp/doesnotexist' }
11
11
12
12
it "'default' => 'value'" do
13
+ allow ( File ) . to receive ( :exist? ) . and_call_original
13
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' )
21
22
let ( :data ) { { 'key' => 'value' , 'ķęŷ' => 'νậŀųề' , 'キー' => '値' } }
22
23
23
24
it "returns 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'" do
25
+ allow ( File ) . to receive ( :exist? ) . and_call_original
24
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 )
31
33
let ( :filename ) { '/tmp/doesexist' }
32
34
33
35
it 'filename /tmp/doesexist' do
36
+ allow ( File ) . to receive ( :exist? ) . and_call_original
34
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' )
You can’t perform that action at this time.
0 commit comments