correct License#all behavior for pseudo licenses when hidden: true

This commit is contained in:
Ben Balter 2018-10-09 14:09:03 -04:00
parent e46cd23849
commit 38a3187587
No known key found for this signature in database
GPG Key ID: DBB67C246AD356C4
3 changed files with 9 additions and 13 deletions

View File

@ -17,7 +17,7 @@ module Licensee
def all(options = {})
@all[options] ||= begin
# TODO: Remove in next major version to avoid breaking change
options[:pseudo] ||= options[:psuedo]
options[:pseudo] ||= options[:psuedo] unless options[:psuedo].nil?
options = DEFAULT_OPTIONS.merge(options)
output = licenses.dup
@ -35,7 +35,7 @@ module Licensee
end
def find(key, options = {})
options = { hidden: true, pseudo: true }.merge(options)
options = { hidden: true }.merge(options)
keys_licenses(options)[key.downcase]
end
alias [] find
@ -128,8 +128,8 @@ module Licensee
# Returns the human-readable license name
def name
return title || spdx_id unless pseudo_license?
key.tr('-', ' ').capitalize
return key.tr('-', ' ').capitalize if pseudo_license?
title || spdx_id
end
def name_without_version

View File

@ -54,8 +54,7 @@ RSpec.describe Licensee::License do
it 'includes hidden licenses' do
expect(licenses).to include(cc_by)
expect(licenses).to include(mit)
expect(licenses).to_not include(other)
expect(licenses.count).to eql(license_count - pseudo_license_count)
expect(licenses.count).to eql(license_count)
end
end
@ -87,10 +86,7 @@ RSpec.describe Licensee::License do
expect(licenses).to include(unlicense)
expect(licenses).to include(cc_by)
expect(licenses).to_not include(mit)
expect(licenses).to_not include(other)
expected = license_count - featured_license_count
expected -= pseudo_license_count
expect(licenses.count).to eql(expected)
expect(licenses.count).to eql(license_count - featured_license_count)
end
end
end
@ -109,8 +105,8 @@ RSpec.describe Licensee::License do
context 'with hidden licenses' do
let(:arguments) { { hidden: true } }
it "doesn't include pseudo licenses" do
expect(licenses).to_not include(other)
it 'includes pseudo licenses' do
expect(licenses).to include(other)
end
end

View File

@ -2,7 +2,7 @@ RSpec.describe Licensee do
let(:project_path) { fixture_path('mit') }
let(:license_path) { fixture_path('mit/LICENSE.txt') }
let(:mit_license) { Licensee::License.find('mit') }
let(:hidden_license_count) { 34 }
let(:hidden_license_count) { 36 }
it 'exposes licenses' do
expect(described_class.licenses).to be_an(Array)