license-acceptance 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ee66c4765774b7f57b1ee20c55138e11bd72071d09cdd1d18fdce1f4888529f
4
- data.tar.gz: 765218350bff46b378b62a103e28f6108f0bf105ed94695b1c51141cfa9e48b4
3
+ metadata.gz: 3857d587ba94db88839300fd30d69123c5adfbf38d1dff100df967d8da698ef5
4
+ data.tar.gz: 24b7cf0a941fed9968c631c5b868c9e31b26a5ce10c0cf8fdb6ec69d105721f1
5
5
  SHA512:
6
- metadata.gz: 607159212194ba650b7c6a5661f7706977dd376192765da07c62d4ef54fcbbe0cfc7a6ed80d7520a1c5c5c97c7a8cdc986d53730deef6b9dd391ae26c7329065
7
- data.tar.gz: 5a45bb60c410d73a286efa1a9c812f977ecc49c1070ac8705c4568f6f4f4ca073127ec6dc4115d108f9996665a309ec30328f9d9b2f461a91d4b36e95133fea2
6
+ metadata.gz: 5a56db6f2962c22c1338521ac254ed7d89862089b8c7a5263a061bf0b4a47a652a8e08332243df50b9c6c1e3cfb589f0ccd49d6a4e7f61143bd31fe45a00e868
7
+ data.tar.gz: c97e284c30fc2d122612a9b7f66220dbba82d6aca37689969d4fdc3aa2c58eced2fc8b61ad0fc17409354de80bfeeb0811db03af568840b5663b7e0a8a957cb3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- license-acceptance (1.0.0)
4
+ license-acceptance (1.0.2)
5
5
  pastel (~> 0.7)
6
6
  tomlrb (~> 1.2)
7
7
  tty-box (~> 0.3)
@@ -103,7 +103,8 @@ module LicenseAcceptance
103
103
  def license_required?(mixlib_name, version)
104
104
  product = product_reader.lookup_by_mixlib(mixlib_name)
105
105
  return false if product.nil?
106
- return true if version == :latest
106
+ # If they don't pass a version we assume they want latest
107
+ return true if version == :latest || version.nil?
107
108
  Gem::Version.new(version) >= Gem::Version.new(product.license_required_version)
108
109
  end
109
110
 
@@ -1,3 +1,3 @@
1
1
  module LicenseAcceptance
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -235,6 +235,54 @@ RSpec.describe LicenseAcceptance::Acceptor do
235
235
  expect(acc.acceptance_value).to eq(nil)
236
236
  end
237
237
  end
238
+ end
239
+
240
+ describe "#license_required?" do
241
+ let(:reader) { instance_double(LicenseAcceptance::ProductReader) }
242
+ let(:mixlib_name) { "chef" }
243
+ let(:version) { "15.0.0" }
244
+ let(:product) { instance_double(LicenseAcceptance::Product, name: "chef-infra", license_required_version: "15.0.0") }
245
+
246
+ before do
247
+ expect(LicenseAcceptance::ProductReader).to receive(:new).and_return(reader)
248
+ expect(reader).to receive(:read)
249
+ end
250
+
251
+ it "returns false if no product can be found" do
252
+ expect(reader).to receive(:lookup_by_mixlib).with(mixlib_name).and_return nil
253
+ expect(acc.license_required?(mixlib_name, version)).to eq(false)
254
+ end
255
+
256
+ describe "when version is :latest" do
257
+ let(:version) { :latest }
258
+ it "returns true" do
259
+ expect(reader).to receive(:lookup_by_mixlib).with(mixlib_name).and_return product
260
+ expect(acc.license_required?(mixlib_name, version)).to eq(true)
261
+ end
262
+ end
263
+
264
+ describe "when version is nil" do
265
+ let(:version) { nil }
266
+ it "returns true" do
267
+ expect(reader).to receive(:lookup_by_mixlib).with(mixlib_name).and_return product
268
+ expect(acc.license_required?(mixlib_name, version)).to eq(true)
269
+ end
270
+ end
238
271
 
272
+ describe "when version is >= than required version" do
273
+ let(:version) { "15.0.0" }
274
+ it "returns true" do
275
+ expect(reader).to receive(:lookup_by_mixlib).with(mixlib_name).and_return product
276
+ expect(acc.license_required?(mixlib_name, version)).to eq(true)
277
+ end
278
+ end
279
+
280
+ describe "when version is < required version" do
281
+ let(:version) { "14.99.99" }
282
+ it "returns false" do
283
+ expect(reader).to receive(:lookup_by_mixlib).with(mixlib_name).and_return product
284
+ expect(acc.license_required?(mixlib_name, version)).to eq(false)
285
+ end
286
+ end
239
287
  end
240
288
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: license-acceptance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - tyler-ball
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-29 00:00:00.000000000 Z
11
+ date: 2019-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pastel