File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change 2626 end
2727
2828 before ( :each ) do
29+ allow ( File ) . to receive ( :exist? ) . and_call_original
2930 allow ( File ) . to receive ( :exist? ) . with ( filename ) . and_return ( false ) . once
3031 if Puppet ::PUPPETVERSION [ 0 ] . to_i < 8
3132 allow ( PSON ) . to receive ( :load ) . never # rubocop:disable RSpec/ReceiveNever Switching to not_to receive breaks testing in this case
5152 let ( :json ) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' }
5253
5354 before ( :each ) do
55+ allow ( File ) . to receive ( :exist? ) . and_call_original
5456 allow ( File ) . to receive ( :exist? ) . with ( filename ) . and_return ( true ) . once
5557 allow ( File ) . to receive ( :read ) . with ( filename ) . and_return ( json ) . once
5658 allow ( File ) . to receive ( :read ) . with ( filename ) . and_return ( json ) . once
7577 let ( :json ) { '{"key":"value"}' }
7678
7779 before ( :each ) do
80+ allow ( File ) . to receive ( :exist? ) . and_call_original
7881 allow ( File ) . to receive ( :exist? ) . with ( filename ) . and_return ( true ) . once
7982 allow ( File ) . to receive ( :read ) . with ( filename ) . and_return ( json ) . once
8083 if Puppet ::PUPPETVERSION [ 0 ] . to_i < 8
Original file line number Diff line number Diff line change 1010 let ( :filename ) { '/tmp/doesnotexist' }
1111
1212 it "'default' => 'value'" do
13+ allow ( File ) . to receive ( :exist? ) . and_call_original
1314 expect ( File ) . to receive ( :exist? ) . with ( filename ) . and_return ( false ) . once
1415 expect ( YAML ) . not_to receive ( :load_file )
1516 expect ( subject ) . to run . with_params ( filename , 'default' => 'value' ) . and_return ( 'default' => 'value' )
2122 let ( :data ) { { 'key' => 'value' , 'ķęŷ' => 'νậŀųề' , 'キー' => '値' } }
2223
2324 it "returns 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'" do
25+ allow ( File ) . to receive ( :exist? ) . and_call_original
2426 expect ( File ) . to receive ( :exist? ) . with ( filename ) . and_return ( true ) . once
2527 expect ( YAML ) . to receive ( :load_file ) . with ( filename ) . and_return ( data ) . once
2628 expect ( subject ) . to run . with_params ( filename ) . and_return ( data )
3133 let ( :filename ) { '/tmp/doesexist' }
3234
3335 it 'filename /tmp/doesexist' do
36+ allow ( File ) . to receive ( :exist? ) . and_call_original
3437 expect ( File ) . to receive ( :exist? ) . with ( filename ) . and_return ( true ) . once
3538 allow ( YAML ) . to receive ( :load_file ) . with ( filename ) . once . and_raise ( StandardError , 'Something terrible have happened!' )
3639 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