spec/licensee/license_spec.rb in licensee-9.12.0 vs spec/licensee/license_spec.rb in licensee-9.13.0
- old
+ new
@@ -1,9 +1,9 @@
# frozen_string_literal: true
RSpec.describe Licensee::License do
- let(:license_count) { 39 }
+ let(:license_count) { 40 }
let(:hidden_license_count) { 27 }
let(:featured_license_count) { 3 }
let(:pseudo_license_count) { 2 }
let(:non_featured_license_count) do
license_count - featured_license_count - hidden_license_count
@@ -33,22 +33,22 @@
context 'without any arguments' do
let(:arguments) { {} }
it 'returns the licenses' do
- expect(licenses).to all be_a(Licensee::License)
+ expect(licenses).to all be_a(described_class)
expect(licenses.count).to eql(license_count - hidden_license_count)
end
it "doesn't include hidden licenses" do
expect(licenses).to all(satisfy { |license| !license.hidden? })
end
it 'includes featured licenses' do
expect(licenses).to include(mit)
- expect(licenses).to_not include(cc_by)
- expect(licenses).to_not include(other)
+ expect(licenses).not_to include(cc_by)
+ expect(licenses).not_to include(other)
end
end
context 'hidden licenses' do
let(:arguments) { { hidden: true } }
@@ -63,46 +63,46 @@
context 'featured licenses' do
let(:arguments) { { featured: true } }
it 'includes only featured licenses' do
expect(licenses).to include(mit)
- expect(licenses).to_not include(cc_by)
- expect(licenses).to_not include(other)
+ expect(licenses).not_to include(cc_by)
+ expect(licenses).not_to include(other)
expect(licenses.count).to eql(featured_license_count)
end
end
context 'non-featured licenses' do
let(:arguments) { { featured: false } }
it 'includes only non-featured licenses' do
expect(licenses).to include(unlicense)
- expect(licenses).to_not include(mit)
- expect(licenses).to_not include(other)
+ expect(licenses).not_to include(mit)
+ expect(licenses).not_to include(other)
expect(licenses.count).to eql(non_featured_license_count)
end
context 'including hidden licenses' do
let(:arguments) { { featured: false, hidden: true } }
it 'includes only non-featured licenses' do
expect(licenses).to include(unlicense)
expect(licenses).to include(cc_by)
- expect(licenses).to_not include(mit)
+ expect(licenses).not_to include(mit)
expect(licenses.count).to eql(license_count - featured_license_count)
end
end
end
context 'pseudo licenses' do
- let(:other) { Licensee::License.find('other') }
+ let(:other) { described_class.find('other') }
context 'by default' do
let(:arguments) { {} }
it "doesn't include pseudo licenses" do
- expect(licenses).to_not include(other)
+ expect(licenses).not_to include(other)
end
end
context 'with hidden licenses' do
let(:arguments) { { hidden: true } }
@@ -122,11 +122,11 @@
context 'when explicitly excluded' do
let(:arguments) { { hidden: true, pseudo: false } }
it "doesn'tincludes psudo licenses" do
- expect(licenses).to_not include(other)
+ expect(licenses).not_to include(other)
end
end
context 'mispelled' do
context 'when explicitly asked' do
@@ -139,11 +139,11 @@
context 'when explicitly excluded' do
let(:arguments) { { hidden: true, psuedo: false } }
it "doesn'tincludes psudo licenses" do
- expect(licenses).to_not include(other)
+ expect(licenses).not_to include(other)
end
end
end
end
end
@@ -195,13 +195,13 @@
it 'exposes special SPDX ID for pseudo licenses' do
expect(other.spdx_id).to eql('NOASSERTION')
expect(no_license.spdx_id).to eql('NONE')
end
- context '#other?' do
+ describe '#other?' do
it 'knows MIT is not other' do
- expect(gpl).to_not be_other
+ expect(gpl).not_to be_other
end
it 'knows the other license is other?' do
expect(other).to be_other
end
@@ -214,11 +214,11 @@
expect(mit.meta['title']).to eql('MIT License')
expect(mit.meta.title).to eql('MIT License')
end
it 'includes defaults' do
- expect(other.meta['hidden']).to eql(true)
+ expect(other.meta['hidden']).to be(true)
end
it 'returns the name' do
expect(mit.name).to eql('MIT License')
end
@@ -236,31 +236,31 @@
expect(mit.name_without_version).to eql('MIT License')
expect(gpl.name_without_version).to eql('GNU General Public License')
end
it 'knows if a license is hidden' do
- expect(mit).to_not be_hidden
+ expect(mit).not_to be_hidden
expect(cc_by).to be_hidden
end
it 'knows if a license is featured' do
expect(mit).to be_featured
- expect(unlicense).to_not be_featured
+ expect(unlicense).not_to be_featured
end
it 'knows if a license is GPL' do
- expect(mit).to_not be_gpl
+ expect(mit).not_to be_gpl
expect(gpl).to be_gpl
end
it 'knows a license is lgpl' do
- expect(mit).to_not be_gpl
+ expect(mit).not_to be_gpl
expect(lgpl).to be_lgpl
end
it 'knows if a license is CC' do
- expect(gpl).to_not be_creative_commons
+ expect(gpl).not_to be_creative_commons
expect(cc_by).to be_creative_commons
end
end
context 'content' do
@@ -299,15 +299,15 @@
expect(mit.url).to eql('http://choosealicense.com/licenses/mit/')
end
it 'knows equality' do
expect(mit).to eql(mit)
- expect(gpl).to_not eql(mit)
+ expect(gpl).not_to eql(mit)
end
it 'knows if a license is a pseudo license' do
- expect(mit).to_not be_pseudo_license
+ expect(mit).not_to be_pseudo_license
expect(other).to be_pseudo_license
end
it 'fails loudly for invalid license' do
expect do
@@ -317,28 +317,28 @@
it 'returns the rules' do
expect(mit.rules).to be_a(Licensee::LicenseRules)
expect(mit.rules).to have_key('permissions')
expect(mit.rules['permissions'].first).to be_a(Licensee::Rule)
- expect(mit.rules.flatten.count).to eql(7)
+ expect(mit.rules.flatten.count).to be(7)
end
it 'returns rules by tag and group' do
expect(cc_by.rules).to have_key('limitations')
rule = cc_by.rules['limitations'].find { |r| r.tag == 'patent-use' }
- expect(rule).to_not be_nil
+ expect(rule).not_to be_nil
expect(rule.description).to include('does NOT grant')
expect(gpl.rules).to have_key('permissions')
rule = gpl.rules['permissions'].find { |r| r.tag == 'patent-use' }
- expect(rule).to_not be_nil
+ expect(rule).not_to be_nil
expect(rule.description).to include('an express grant of patent rights')
end
context 'fields' do
it 'returns the license fields' do
- expect(mit.fields.count).to eql(2)
+ expect(mit.fields.count).to be(2)
expect(mit.fields.first.key).to eql('year')
expect(mit.fields.last.key).to eql('fullname')
expect(gpl.fields).to be_empty
end
@@ -351,23 +351,23 @@
end
it 'returns mustache content' do
expect(license.content_for_mustache).to match(/{{{year}}}/)
expect(license.content_for_mustache).to match(/{{{fullname}}}/)
- expect(license.content_for_mustache).to_not match(/\[year\]/)
- expect(license.content_for_mustache).to_not match(/\[fullname\]/)
+ expect(license.content_for_mustache).not_to match(/\[year\]/)
+ expect(license.content_for_mustache).not_to match(/\[fullname\]/)
end
it "doesn't mangle other fields" do
expect(license.content_for_mustache).to match(/\[foo\]/)
- expect(license.content_for_mustache).to_not match(/{{{foo}}}/)
+ expect(license.content_for_mustache).not_to match(/{{{foo}}}/)
end
end
end
context 'License.title_regex' do
- Licensee::License.all(hidden: true, pseudo: false).each do |license|
+ described_class.all(hidden: true, pseudo: false).each do |license|
context "the #{license.title} license" do
%i[title nickname key].each do |variation|
next if license.send(variation).nil?
context "the license #{variation}" do
@@ -438,11 +438,11 @@
end
end
context 'a license with an alt title' do
let(:text) { 'The Clear BSD license' }
- let(:license) { Licensee::License.find('bsd-3-clause-clear') }
+ let(:license) { described_class.find('bsd-3-clause-clear') }
it 'matches' do
expect(text).to match(license.title_regex)
end
@@ -473,10 +473,10 @@
expect(hash).to eql(expected)
end
end
context 'source regex' do
- Licensee::License.all(hidden: true, pseudo: false).each do |license|
+ described_class.all(hidden: true, pseudo: false).each do |license|
context "the #{license.title} license" do
let(:source) { URI.parse(license.source) }
%w[http https].each do |scheme|
context "with a #{scheme}:// scheme" do