beaker-module_install_helper 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 823c0eb3935f314373fd6a2a69c48a4f00e3cbca
4
- data.tar.gz: 7ce9f9efee93bacc80f76247359271992d84bddf
3
+ metadata.gz: 335eced6501675a1215d9492779c7efca77c62bc
4
+ data.tar.gz: 32c5045a4faed8fc92bc44e019164f6d711b9176
5
5
  SHA512:
6
- metadata.gz: eae59a8d7a8bcd82382ec9d59a93d840b18a6e186199e2b92c7cb135a8b1af7a11460c11886bde8187293000adee2a7c96d355ef6694e307508f5dd80745bb87
7
- data.tar.gz: fd2afeff327e32091ac6600c53090edc763f5f73e0b7c81dc7968fbdfea75642e96aab45ab8998c551fb5db70b27140fdd8932f13acc4b163151f41e4c7bedb7
6
+ metadata.gz: 53e39c82c94044ee48d18d07004b47dd0e55dc90427f976e924a49044c6416c1d2a7080dda980420372a7947f62bd04fd87ef518736152f79fdb27b55ce180d6
7
+ data.tar.gz: 23e6824f988c904633fde2338bce5fb72c4950a1cefa093df1113cbc43ef1551ea43dbc9b772c3e0855066e07acd797c890dc66a47c03a7aca1ccb31d46f39fb
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'beaker-module_install_helper'
7
- spec.version = '0.1.2'
7
+ spec.version = '0.1.3'
8
8
  spec.authors = ['Puppet']
9
9
  spec.email = ['wilson@puppet.com']
10
10
 
@@ -86,7 +86,7 @@ module Beaker::ModuleInstallHelper
86
86
  # and upper bounds. The function then uses the forge rest endpoint to find
87
87
  # the most recent release of the given module matching the version requirement
88
88
  def module_version_from_requirement(mod_name, vr_str)
89
- uri = URI("#{forge_api}/v3/modules/#{mod_name}")
89
+ uri = URI("#{forge_api}v3/modules/#{mod_name}")
90
90
  response = Net::HTTP.get(uri)
91
91
  forge_data = JSON.parse(response)
92
92
 
@@ -170,18 +170,24 @@ module Beaker::ModuleInstallHelper
170
170
 
171
171
  def forge_host
172
172
  fh = ENV['BEAKER_FORGE_HOST']
173
- return fh unless fh.nil?
173
+ unless fh.nil?
174
+ fh = 'https://' + fh if fh !~ /^(https:\/\/|http:\/\/)/i
175
+ fh += '/' unless fh != /\/$/
176
+ return fh
177
+ end
178
+
174
179
  'https://forge.puppet.com/'
175
180
  end
176
181
 
177
182
  def forge_api
178
- fh = forge_host
179
- return 'https://forgeapi.puppetlabs.com' if fh == 'https://forge.puppet.com/'
180
-
181
183
  fa = ENV['BEAKER_FORGE_API']
182
- return fa.gsub(/\/$/, '') unless fa.nil?
184
+ unless fa.nil?
185
+ fa = 'https://' + fa if fa !~ /^(https:\/\/|http:\/\/)/i
186
+ fa += '/' unless fa != /\/$/
187
+ return fa
188
+ end
183
189
 
184
- raise 'Must specify BEAKER_FORGE_API env variable when specifying custom forge host'
190
+ 'https://forgeapi.puppetlabs.com/'
185
191
  end
186
192
  end
187
193
 
@@ -242,27 +242,16 @@ describe Beaker::ModuleInstallHelper do
242
242
  allow(ENV).to receive(:[]).with('BEAKER_FORGE_HOST').and_return(nil)
243
243
  allow(ENV).to receive(:[]).with('BEAKER_FORGE_API').and_return(nil)
244
244
 
245
- expect(forge_api).to eq('https://forgeapi.puppetlabs.com')
245
+ expect(forge_api).to eq('https://forgeapi.puppetlabs.com/')
246
246
  end
247
247
  end
248
248
 
249
249
  context 'with BEAKER_FORGE_HOST and BEAKER_FORGE_API env variables specified' do
250
- context 'without trailing slash' do
251
- it 'returns specified forge api' do
252
- allow(ENV).to receive(:[]).with('BEAKER_FORGE_HOST').and_return('custom')
253
- allow(ENV).to receive(:[]).with('BEAKER_FORGE_API').and_return('an-api-url')
250
+ it 'returns specified forge api with trailing slash' do
251
+ allow(ENV).to receive(:[]).with('BEAKER_FORGE_HOST').and_return('custom')
252
+ allow(ENV).to receive(:[]).with('BEAKER_FORGE_API').and_return('an-api-url/')
254
253
 
255
- expect(forge_api).to eq('an-api-url')
256
- end
257
- end
258
-
259
- context 'with trailing slash' do
260
- it 'returns specified forge api without trailing slash' do
261
- allow(ENV).to receive(:[]).with('BEAKER_FORGE_HOST').and_return('custom')
262
- allow(ENV).to receive(:[]).with('BEAKER_FORGE_API').and_return('an-api-url/')
263
-
264
- expect(forge_api).to eq('an-api-url')
265
- end
254
+ expect(forge_api).to eq('https://an-api-url/')
266
255
  end
267
256
  end
268
257
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-module_install_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-02 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec