|
7 | 7 |
|
8 | 8 | describe "when calling with valid arguments" do |
9 | 9 | before :each do |
10 | | - if RSpec.configuration.puppet_future |
11 | | - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') |
12 | | - else |
13 | | - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') |
14 | | - end |
| 10 | + allow(File).to receive(:read).with(/\/stdlib\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') |
| 11 | + allow(File).to receive(:read).with(/\/stdlib\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') |
15 | 12 | end |
16 | 13 | it "should json parse the file" do |
17 | | - allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') |
18 | | - allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(true) |
19 | | - allow(File).to receive(:read).with('/path/to/module/metadata.json').and_return('{"name": "spencer-science"}') |
| 14 | + if Puppet::Util::Platform.windows? |
| 15 | + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/') |
| 16 | + allow(File).to receive(:exists?).with('C:/path/to/module/metadata.json').and_return(true) |
| 17 | + allow(File).to receive(:read).with('C:/path/to/module/metadata.json').and_return('{"name": "spencer-science"}') |
| 18 | + else |
| 19 | + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') |
| 20 | + allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(true) |
| 21 | + allow(File).to receive(:read).with('/path/to/module/metadata.json').and_return('{"name": "spencer-science"}') |
| 22 | + end |
20 | 23 |
|
21 | 24 | result = subject.call(['science']) |
22 | 25 | expect(result['name']).to eq('spencer-science') |
23 | 26 | end |
24 | 27 |
|
25 | 28 | it "should fail by default if there is no metadata.json" do |
26 | | - allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') |
27 | | - allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false) |
| 29 | + if Puppet::Util::Platform.windows? |
| 30 | + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/') |
| 31 | + allow(File).to receive(:exists?).with('C:/path/to/module/metadata.json').and_return(false) |
| 32 | + else |
| 33 | + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') |
| 34 | + allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false) |
| 35 | + end |
28 | 36 | expect {subject.call(['science'])}.to raise_error(Puppet::ParseError) |
29 | 37 | end |
30 | 38 |
|
31 | 39 | it "should return nil if user allows empty metadata.json" do |
32 | | - allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') |
33 | | - allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false) |
| 40 | + if Puppet::Util::Platform.windows? |
| 41 | + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/') |
| 42 | + allow(File).to receive(:exists?).with('C:/path/to/module/metadata.json').and_return(false) |
| 43 | + else |
| 44 | + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') |
| 45 | + allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false) |
| 46 | + end |
34 | 47 | result = subject.call(['science', true]) |
35 | 48 | expect(result).to eq({}) |
36 | 49 | end |
|
0 commit comments