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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/license_acceptance/acceptor.rb +2 -1
- data/lib/license_acceptance/version.rb +1 -1
- data/spec/license_acceptance/acceptor_spec.rb +48 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3857d587ba94db88839300fd30d69123c5adfbf38d1dff100df967d8da698ef5
|
4
|
+
data.tar.gz: 24b7cf0a941fed9968c631c5b868c9e31b26a5ce10c0cf8fdb6ec69d105721f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a56db6f2962c22c1338521ac254ed7d89862089b8c7a5263a061bf0b4a47a652a8e08332243df50b9c6c1e3cfb589f0ccd49d6a4e7f61143bd31fe45a00e868
|
7
|
+
data.tar.gz: c97e284c30fc2d122612a9b7f66220dbba82d6aca37689969d4fdc3aa2c58eced2fc8b61ad0fc17409354de80bfeeb0811db03af568840b5663b7e0a8a957cb3
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
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
|
|
@@ -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.
|
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-
|
11
|
+
date: 2019-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pastel
|