|
55 | 55 | allow(File).to receive(:exist?).and_call_original |
56 | 56 | allow(File).to receive(:exist?).with(filename).and_return(true).once |
57 | 57 | allow(File).to receive(:read).with(filename).and_return(json).once |
58 | | - allow(File).to receive(:read).with(filename).and_return(json).once |
59 | 58 | if Puppet::PUPPETVERSION[0].to_i < 8 |
60 | 59 | allow(PSON).to receive(:load).with(json).and_return(data).once |
61 | 60 | else |
|
98 | 97 | let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' } |
99 | 98 |
|
100 | 99 | it { |
101 | | - expect(OpenURI).to receive(:open_uri).with(filename, {}).and_return(json) |
| 100 | + expect(OpenURI).to receive(:open_uri).with(filename, {}).and_return(StringIO.new(json)) |
102 | 101 | if Puppet::PUPPETVERSION[0].to_i < 8 |
103 | 102 | expect(PSON).to receive(:load).with(json).and_return(data).once |
104 | 103 | else |
|
118 | 117 | let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' } |
119 | 118 |
|
120 | 119 | it { |
121 | | - expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(json) |
| 120 | + expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(StringIO.new(json)) |
122 | 121 | if Puppet::PUPPETVERSION[0].to_i < 8 |
123 | 122 | expect(PSON).to receive(:load).with(json).and_return(data).once |
124 | 123 | else |
|
138 | 137 | let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' } |
139 | 138 |
|
140 | 139 | it { |
141 | | - expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(json) |
| 140 | + expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(StringIO.new(json)) |
142 | 141 | if Puppet::PUPPETVERSION[0].to_i < 8 |
143 | 142 | expect(PSON).to receive(:load).with(json).and_return(data).once |
144 | 143 | else |
|
155 | 154 | let(:json) { ',;{"key":"value"}' } |
156 | 155 |
|
157 | 156 | it { |
158 | | - expect(OpenURI).to receive(:open_uri).with(filename, {}).and_return(json) |
| 157 | + expect(OpenURI).to receive(:open_uri).with(filename, {}).and_return(StringIO.new(json)) |
159 | 158 | if Puppet::PUPPETVERSION[0].to_i < 8 |
160 | 159 | expect(PSON).to receive(:load).with(json).once.and_raise StandardError, 'Something terrible have happened!' |
161 | 160 | else |
|
0 commit comments