1111 facts
1212 end
1313
14+ let ( :npm_path ) do
15+ if os =~ /freebsd/i
16+ '/usr/local/bin/npm'
17+ else
18+ '/usr/bin/npm'
19+ end
20+ end
21+
22+
1423 context 'with name set to proxy and value set to proxy.domain' do
1524 let ( :title ) { 'proxy' }
1625 let :params do
2029 end
2130
2231 it 'npm config set proxy proxy.domain should be executed' do
23- is_expected . to contain_exec ( 'npm_config present proxy' ) . with ( 'command' => '/usr/bin/npm config set proxy proxy.domain --global' )
32+ is_expected . to contain_exec ( 'npm_config present proxy' ) . with ( 'command' => " #{ npm_path } config set proxy proxy.domain --global" )
2433 end
2534 end
2635
3342 end
3443
3544 it 'npm config set https-proxy proxy.domain should be executed' do
36- is_expected . to contain_exec ( 'npm_config present https-proxy' ) . with ( 'command' => '/usr/bin/npm config set https-proxy proxy.domain --global' )
45+ is_expected . to contain_exec ( 'npm_config present https-proxy' ) . with ( 'command' => " #{ npm_path } config set https-proxy proxy.domain --global" )
3746 end
3847 end
3948
4655 end
4756
4857 it 'npm config delete color should be executed' do
49- is_expected . to contain_exec ( 'npm_config absent color' ) . with ( 'command' => '/usr/bin/npm config delete color --global' )
58+ is_expected . to contain_exec ( 'npm_config absent color' ) . with ( 'command' => " #{ npm_path } config delete color --global" )
5059 end
5160 end
5261
6069 end
6170
6271 it 'npm config set :_secret should be executed' do
63- is_expected . to contain_exec ( 'npm_config present //path.to.registry/:_secret' ) . with ( 'command' => '/usr/bin/npm config set //path.to.registry/:_secret cGFzc3dvcmQ= --global' )
72+ is_expected . to contain_exec ( 'npm_config present //path.to.registry/:_secret' ) . with ( 'command' => " #{ npm_path } config set //path.to.registry/:_secret cGFzc3dvcmQ= --global" )
6473 end
6574 end
6675
@@ -82,11 +91,11 @@ class { 'nodejs':
8291 end
8392
8493 it 'npm config set prefer-online should be executed and require npm package' do
85- is_expected . to contain_exec ( 'npm_config present prefer-online' ) . with ( 'command' => '/usr/bin/npm config set prefer-online true --global' ) . that_requires ( 'Package[npm-package-name]' )
94+ is_expected . to contain_exec ( 'npm_config present prefer-online' ) . with ( 'command' => " #{ npm_path } config set prefer-online true --global" ) . that_requires ( 'Package[npm-package-name]' )
8695 end
8796
8897 it 'npm config set prefer-online should not require node package' do
89- is_expected . not_to contain_exec ( 'npm_config present prefer-online' ) . with ( 'command' => '/usr/bin/npm config set prefer-online true --global' ) . that_requires ( 'Package[node-package-name]' )
98+ is_expected . not_to contain_exec ( 'npm_config present prefer-online' ) . with ( 'command' => " #{ npm_path } config set prefer-online true --global" ) . that_requires ( 'Package[node-package-name]' )
9099 end
91100 end
92101
@@ -108,7 +117,7 @@ class { 'nodejs':
108117 end
109118
110119 it 'npm config set loglevel should be executed and require nodejs package' do
111- is_expected . to contain_exec ( 'npm_config present loglevel' ) . with ( 'command' => '/usr/bin/npm config set loglevel debug --global' ) . that_requires ( 'Package[node-package-name]' )
120+ is_expected . to contain_exec ( 'npm_config present loglevel' ) . with ( 'command' => " #{ npm_path } config set loglevel debug --global" ) . that_requires ( 'Package[node-package-name]' )
112121 end
113122 end
114123
@@ -132,15 +141,15 @@ class { 'nodejs':
132141 end
133142
134143 it 'npm config set init-version should be executed' do
135- is_expected . to contain_exec ( 'npm_config present init-version' ) . with ( 'command' => '/usr/bin/npm config set init-version 0.0.1 --global' )
144+ is_expected . to contain_exec ( 'npm_config present init-version' ) . with ( 'command' => " #{ npm_path } config set init-version 0.0.1 --global" )
136145 end
137146
138147 it 'npm config set init-version should not require npm package' do
139- is_expected . not_to contain_exec ( 'npm_config present init-version' ) . with ( 'command' => '/usr/bin/npm config set init-version 0.0.1 --global' ) . that_requires ( 'Package[npm-package-name]' )
148+ is_expected . not_to contain_exec ( 'npm_config present init-version' ) . with ( 'command' => " #{ npm_path } config set init-version 0.0.1 --global" ) . that_requires ( 'Package[npm-package-name]' )
140149 end
141150
142151 it 'npm config set init-version should not require node package' do
143- is_expected . not_to contain_exec ( 'npm_config present init-version' ) . with ( 'command' => '/usr/bin/npm config set init-version 0.0.1 --global' ) . that_requires ( 'Package[node-package-name]' )
152+ is_expected . not_to contain_exec ( 'npm_config present init-version' ) . with ( 'command' => " #{ npm_path } config set init-version 0.0.1 --global" ) . that_requires ( 'Package[node-package-name]' )
144153 end
145154 end
146155 end
0 commit comments