|
95 | 95 | let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' } |
96 | 96 |
|
97 | 97 | it { |
| 98 | + expect(OpenURI).to receive(:open_uri).with(filename, {}).and_return(json) |
98 | 99 | if Puppet::PUPPETVERSION[0].to_i < 8 |
99 | | - expect(OpenURI).to receive(:open_uri).with(filename, {}).and_return(json) |
100 | 100 | expect(PSON).to receive(:load).with(json).and_return(data).once |
101 | 101 | else |
102 | | - expect(URI).to receive(:open).with(filename).and_return(json) |
103 | 102 | expect(JSON).to receive(:parse).with(json).and_return(data).once |
104 | 103 | end |
105 | 104 | expect(subject).to run.with_params(filename).and_return(data) |
|
116 | 115 | let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' } |
117 | 116 |
|
118 | 117 | it { |
| 118 | + expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(json) |
119 | 119 | if Puppet::PUPPETVERSION[0].to_i < 8 |
120 | | - expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(json) |
121 | 120 | expect(PSON).to receive(:load).with(json).and_return(data).once |
122 | 121 | else |
123 | | - expect(URI).to receive(:open).with(url_no_auth, basic_auth).and_return(json) |
124 | 122 | expect(JSON).to receive(:parse).with(json).and_return(data).once |
125 | 123 | end |
126 | 124 | expect(subject).to run.with_params(filename).and_return(data) |
|
137 | 135 | let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' } |
138 | 136 |
|
139 | 137 | it { |
| 138 | + expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(json) |
140 | 139 | if Puppet::PUPPETVERSION[0].to_i < 8 |
141 | | - expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(json) |
142 | 140 | expect(PSON).to receive(:load).with(json).and_return(data).once |
143 | 141 | else |
144 | | - expect(URI).to receive(:open).with(url_no_auth, basic_auth).and_return(json) |
145 | 142 | expect(JSON).to receive(:parse).with(json).and_return(data).once |
146 | 143 | end |
147 | 144 | expect(subject).to run.with_params(filename).and_return(data) |
|
155 | 152 | let(:json) { ',;{"key":"value"}' } |
156 | 153 |
|
157 | 154 | it { |
| 155 | + expect(OpenURI).to receive(:open_uri).with(filename, {}).and_return(json) |
158 | 156 | if Puppet::PUPPETVERSION[0].to_i < 8 |
159 | | - expect(OpenURI).to receive(:open_uri).with(filename, {}).and_return(json) |
160 | 157 | expect(PSON).to receive(:load).with(json).once.and_raise StandardError, 'Something terrible have happened!' |
161 | 158 | else |
162 | | - expect(URI).to receive(:open).with(filename).and_return(json) |
163 | 159 | expect(JSON).to receive(:parse).with(json).once.and_raise StandardError, 'Something terrible have happened!' |
164 | 160 | end |
165 | 161 | expect(subject).to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') |
|
172 | 168 | end |
173 | 169 |
|
174 | 170 | it { |
175 | | - if Puppet::PUPPETVERSION[0].to_i < 8 |
176 | | - expect(OpenURI).to receive(:open_uri).with(filename, {}).and_raise OpenURI::HTTPError, '404 File not Found' |
177 | | - else |
178 | | - expect(URI).to receive(:open).with(filename).and_raise URI::Error, '404 File not Found' |
179 | | - end |
| 171 | + expect(OpenURI).to receive(:open_uri).with(filename, {}).and_raise OpenURI::HTTPError, '404 File not Found' |
180 | 172 | expect(subject).to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') |
181 | 173 | } |
182 | 174 | end |
|
0 commit comments