license_finder 0.8.0-java
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.
- data/.gitignore +12 -0
- data/.rspec +1 -0
- data/.travis.yml +15 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/Rakefile +21 -0
- data/bin/license_finder +54 -0
- data/db/migrate/201303290935_create_dependencies.rb +14 -0
- data/db/migrate/201303291155_create_licenses.rb +13 -0
- data/db/migrate/201303291402_create_approvals.rb +13 -0
- data/db/migrate/201303291456_create_ancestries.rb +9 -0
- data/db/migrate/201303291519_create_bundler_groups.rb +13 -0
- data/db/migrate/201303291720_move_manual_from_approvals_to_licenses.rb +11 -0
- data/db/migrate/201303291753_allow_null_license_names.rb +7 -0
- data/db/migrate/201304011027_allow_null_dependency_version.rb +7 -0
- data/db/migrate/201304020947_change_table_name_licenses_to_license_aliases.rb +5 -0
- data/features/approve_dependencies.feature +14 -0
- data/features/html_report.feature +38 -0
- data/features/ignore_bundle_groups.feature +11 -0
- data/features/license_finder.feature +47 -0
- data/features/license_finder_rake_task.feature +37 -0
- data/features/rails_rake.feature +9 -0
- data/features/set_license.feature +12 -0
- data/features/step_definitions/license_finder_steps.rb +25 -0
- data/features/step_definitions/steps.rb +376 -0
- data/features/text_report.feature +27 -0
- data/features/whitelist.feature +24 -0
- data/files/license_finder.yml +8 -0
- data/lib/data/licenses/Apache2.txt +172 -0
- data/lib/data/licenses/BSD.txt +24 -0
- data/lib/data/licenses/GPLv2.txt +339 -0
- data/lib/data/licenses/ISC.txt +2 -0
- data/lib/data/licenses/LGPL.txt +165 -0
- data/lib/data/licenses/MIT.txt +9 -0
- data/lib/data/licenses/NewBSD.txt +21 -0
- data/lib/data/licenses/Ruby.txt +52 -0
- data/lib/data/licenses/SimplifiedBSD.txt +23 -0
- data/lib/license_finder.rb +47 -0
- data/lib/license_finder/bundle.rb +48 -0
- data/lib/license_finder/bundle_syncer.rb +11 -0
- data/lib/license_finder/bundled_gem.rb +48 -0
- data/lib/license_finder/cli.rb +49 -0
- data/lib/license_finder/configuration.rb +71 -0
- data/lib/license_finder/dependency_report.rb +30 -0
- data/lib/license_finder/gem_saver.rb +69 -0
- data/lib/license_finder/html_report.rb +14 -0
- data/lib/license_finder/license.rb +90 -0
- data/lib/license_finder/license/apache2.rb +8 -0
- data/lib/license_finder/license/bsd.rb +4 -0
- data/lib/license_finder/license/gplv2.rb +4 -0
- data/lib/license_finder/license/isc.rb +3 -0
- data/lib/license_finder/license/lgpl.rb +3 -0
- data/lib/license_finder/license/mit.rb +23 -0
- data/lib/license_finder/license/new_bsd.rb +8 -0
- data/lib/license_finder/license/ruby.rb +11 -0
- data/lib/license_finder/license/simplified_bsd.rb +8 -0
- data/lib/license_finder/license_files.rb +36 -0
- data/lib/license_finder/license_url.rb +12 -0
- data/lib/license_finder/platform.rb +32 -0
- data/lib/license_finder/possible_license_file.rb +32 -0
- data/lib/license_finder/railtie.rb +7 -0
- data/lib/license_finder/reporter.rb +20 -0
- data/lib/license_finder/tables.rb +7 -0
- data/lib/license_finder/tables/approval.rb +4 -0
- data/lib/license_finder/tables/bundler_group.rb +4 -0
- data/lib/license_finder/tables/dependency.rb +31 -0
- data/lib/license_finder/tables/license_alias.rb +22 -0
- data/lib/license_finder/text_report.rb +9 -0
- data/lib/license_finder/yml_to_sql.rb +127 -0
- data/lib/tasks/license_finder.rake +7 -0
- data/lib/templates/html_report.erb +111 -0
- data/lib/templates/text_report.erb +3 -0
- data/license_finder.gemspec +36 -0
- data/readme.md +115 -0
- data/spec/fixtures/APACHE-2-LICENSE +202 -0
- data/spec/fixtures/GPLv2 +339 -0
- data/spec/fixtures/ISC-LICENSE +10 -0
- data/spec/fixtures/MIT-LICENSE +22 -0
- data/spec/fixtures/MIT-LICENSE-with-varied-disclaimer +22 -0
- data/spec/fixtures/README-with-MIT-LICENSE +222 -0
- data/spec/fixtures/license_directory/COPYING +0 -0
- data/spec/fixtures/license_directory/LICENSE/BSD-2-Clause.txt +25 -0
- data/spec/fixtures/license_directory/LICENSE/GPL-2.0.txt +339 -0
- data/spec/fixtures/license_directory/LICENSE/LICENSE +191 -0
- data/spec/fixtures/license_directory/LICENSE/MIT.txt +21 -0
- data/spec/fixtures/license_directory/LICENSE/RUBY.txt +60 -0
- data/spec/fixtures/license_names/COPYING.txt +0 -0
- data/spec/fixtures/license_names/LICENSE +0 -0
- data/spec/fixtures/license_names/Licence.rdoc +0 -0
- data/spec/fixtures/license_names/Mit-License +0 -0
- data/spec/fixtures/license_names/README.rdoc +0 -0
- data/spec/fixtures/mit_licensed_gem/LICENSE +22 -0
- data/spec/fixtures/nested_gem/vendor/LICENSE +0 -0
- data/spec/fixtures/nested_readme/vendor/README +0 -0
- data/spec/fixtures/other_licensed_gem/LICENSE +3 -0
- data/spec/fixtures/readme/Project ReadMe b/data/spec/fixtures/readme/Project → ReadMe +0 -0
- data/spec/fixtures/readme/README +0 -0
- data/spec/fixtures/readme/Readme.markdown +0 -0
- data/spec/fixtures/utf8_gem/README +210 -0
- data/spec/lib/license_finder/bundle_spec.rb +61 -0
- data/spec/lib/license_finder/bundle_syncer_spec.rb +16 -0
- data/spec/lib/license_finder/bundled_gem_spec.rb +62 -0
- data/spec/lib/license_finder/cli_spec.rb +38 -0
- data/spec/lib/license_finder/configuration_spec.rb +70 -0
- data/spec/lib/license_finder/gem_saver_spec.rb +155 -0
- data/spec/lib/license_finder/html_report_spec.rb +84 -0
- data/spec/lib/license_finder/license/apache_spec.rb +7 -0
- data/spec/lib/license_finder/license/bsd_spec.rb +41 -0
- data/spec/lib/license_finder/license/gplv2_spec.rb +7 -0
- data/spec/lib/license_finder/license/isc_spec.rb +7 -0
- data/spec/lib/license_finder/license/lgpl_spec.rb +7 -0
- data/spec/lib/license_finder/license/mit_spec.rb +33 -0
- data/spec/lib/license_finder/license/new_bsd_spec.rb +35 -0
- data/spec/lib/license_finder/license/ruby_spec.rb +19 -0
- data/spec/lib/license_finder/license/simplified_bsd_spec.rb +7 -0
- data/spec/lib/license_finder/license_files_spec.rb +50 -0
- data/spec/lib/license_finder/license_spec.rb +45 -0
- data/spec/lib/license_finder/license_url_spec.rb +20 -0
- data/spec/lib/license_finder/possible_license_file_spec.rb +37 -0
- data/spec/lib/license_finder/reporter_spec.rb +4 -0
- data/spec/lib/license_finder/tables/dependency_spec.rb +102 -0
- data/spec/lib/license_finder/tables/license_alias_spec.rb +54 -0
- data/spec/lib/license_finder/text_report_spec.rb +31 -0
- data/spec/lib/license_finder/yml_to_sql_spec.rb +99 -0
- data/spec/lib/license_finder_spec.rb +82 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/support/license_examples.rb +30 -0
- metadata +435 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module LicenseFinder
|
|
4
|
+
describe CLI do
|
|
5
|
+
describe "#execute!(options)" do
|
|
6
|
+
before { CLI.stub(:check_for_action_items) }
|
|
7
|
+
|
|
8
|
+
context "when the approve option is provided" do
|
|
9
|
+
it "should approve the requested gem" do
|
|
10
|
+
dependency = double('dependency', :name => nil)
|
|
11
|
+
dependency.should_receive(:approve!)
|
|
12
|
+
|
|
13
|
+
Dependency.stub(:first).with(name: 'foo').and_return(dependency)
|
|
14
|
+
|
|
15
|
+
CLI.execute! approve: true, dependency: 'foo'
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
context "when the -l (--license) switch is provided" do
|
|
20
|
+
it "should update the license on the requested gem" do
|
|
21
|
+
dependency = double :dependency, :name => nil
|
|
22
|
+
dependency.should_receive(:set_license_manually).with("foo")
|
|
23
|
+
|
|
24
|
+
Dependency.stub(:first).with(name: "foo_gem").and_return dependency
|
|
25
|
+
|
|
26
|
+
CLI.execute! license: "foo", dependency: 'foo_gem'
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context "when no options are provided" do
|
|
31
|
+
it "should check for action items" do
|
|
32
|
+
CLI.should_receive(:check_for_action_items)
|
|
33
|
+
CLI.execute!
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module LicenseFinder
|
|
4
|
+
describe Configuration do
|
|
5
|
+
let(:config) { described_class.new }
|
|
6
|
+
|
|
7
|
+
let(:klass) { described_class }
|
|
8
|
+
|
|
9
|
+
describe '.new' do
|
|
10
|
+
let(:attributes) do
|
|
11
|
+
{
|
|
12
|
+
"whitelist" => ["FooLicense", "BarLicense"],
|
|
13
|
+
"ignore_groups" => [:test, :development],
|
|
14
|
+
"dependencies_file_dir" => "."
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
subject { klass.new(attributes) }
|
|
19
|
+
|
|
20
|
+
context "with known attributes" do
|
|
21
|
+
it "should set the all of the attributes on the instance" do
|
|
22
|
+
subject.whitelist.should == attributes['whitelist']
|
|
23
|
+
subject.ignore_groups.should == attributes['ignore_groups']
|
|
24
|
+
subject.dependencies_dir.should == attributes['dependencies_file_dir']
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "uses absolute path in database_path" do
|
|
29
|
+
subject.database_path.should_not start_with(".")
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "#whitelist" do
|
|
34
|
+
it "should default to an empty array" do
|
|
35
|
+
klass.new.whitelist.should == []
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "whitelisted?" do
|
|
40
|
+
context "canonical name whitelisted" do
|
|
41
|
+
before { config.whitelist = [License::Apache2.names[rand(License::Apache2.names.count)]]}
|
|
42
|
+
|
|
43
|
+
let(:possible_license_names) { License::Apache2.names }
|
|
44
|
+
|
|
45
|
+
it "should return true if if the license is the canonical name, pretty name, or alternative name of the license" do
|
|
46
|
+
possible_license_names.each do |name|
|
|
47
|
+
config.whitelisted?(name).should be_true, "expected #{name} to be whitelisted, but wasn't."
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should be case-insensitive" do
|
|
52
|
+
possible_license_names.map(&:downcase).each do |name|
|
|
53
|
+
config.whitelisted?(name).should be_true, "expected #{name} to be whitelisted, but wasn't"
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "#ignore_groups" do
|
|
60
|
+
it "should default to an empty array" do
|
|
61
|
+
config.ignore_groups.should == []
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should always return symbolized versions of the ignore groups" do
|
|
65
|
+
config.ignore_groups = %w[test development]
|
|
66
|
+
config.ignore_groups.should == [:test, :development]
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module LicenseFinder
|
|
4
|
+
describe GemSaver do
|
|
5
|
+
let(:gemspec) do
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = 'spec_name'
|
|
8
|
+
s.version = '2.1.3'
|
|
9
|
+
s.summary = 'summary'
|
|
10
|
+
s.description = 'description'
|
|
11
|
+
s.homepage = 'homepage'
|
|
12
|
+
|
|
13
|
+
s.add_dependency 'foo'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "#save" do
|
|
18
|
+
let(:bundled_gem) { BundledGem.new(gemspec) }
|
|
19
|
+
subject { described_class.find_or_initialize_by_name('spec_name', bundled_gem).save }
|
|
20
|
+
|
|
21
|
+
context "when the dependency is new" do
|
|
22
|
+
it "persists gem data" do
|
|
23
|
+
subject.id.should be
|
|
24
|
+
subject.name.should == "spec_name"
|
|
25
|
+
subject.version.should == "2.1.3"
|
|
26
|
+
subject.summary.should == "summary"
|
|
27
|
+
subject.description.should == "description"
|
|
28
|
+
subject.homepage.should == "homepage"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "associates children" do
|
|
32
|
+
subject.children.map(&:name).should == ['foo']
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "marks depenency as unapproved by default" do
|
|
36
|
+
subject.approval.state.should == nil
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context "with a bundler dependency" do
|
|
40
|
+
let(:bundled_gem) { BundledGem.new(gemspec, stub(:bundler_dependency, groups: %w[1 2 3]))}
|
|
41
|
+
|
|
42
|
+
it "saves the bundler groups" do
|
|
43
|
+
subject.bundler_groups.map(&:name).should =~ %w[1 2 3]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
context "when the dependency already existed" do
|
|
49
|
+
let!(:old_copy) do
|
|
50
|
+
Dependency.create(
|
|
51
|
+
name: 'spec_name',
|
|
52
|
+
version: '0.1.2',
|
|
53
|
+
summary: 'old summary',
|
|
54
|
+
description: 'old desription',
|
|
55
|
+
homepage: 'old homepage'
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "merges in the latest data" do
|
|
60
|
+
subject.id.should == old_copy.id
|
|
61
|
+
subject.name.should == old_copy.name
|
|
62
|
+
subject.version.should == "2.1.3"
|
|
63
|
+
subject.summary.should == "summary"
|
|
64
|
+
subject.description.should == "description"
|
|
65
|
+
subject.homepage.should == "homepage"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "keeps a manually assigned license" do
|
|
69
|
+
old_copy.license = LicenseAlias.create(name: 'foo', manual: true)
|
|
70
|
+
old_copy.save
|
|
71
|
+
subject.license.name.should == 'foo'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "keeps approval" do
|
|
75
|
+
old_copy.approval = Approval.create(state: true)
|
|
76
|
+
old_copy.save
|
|
77
|
+
subject.approval.state.should == true
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "ensures correct children are associated" do
|
|
81
|
+
old_copy.add_child Dependency.new(name: 'bob')
|
|
82
|
+
old_copy.add_child Dependency.new(name: 'joe')
|
|
83
|
+
old_copy.children.each(&:save)
|
|
84
|
+
subject.children.map(&:name).should =~ ['foo']
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
context "with a bundler dependency" do
|
|
88
|
+
let(:bundled_gem) { BundledGem.new(gemspec, stub(:bundler_dependency, groups: %w[1 2 3]))}
|
|
89
|
+
|
|
90
|
+
before do
|
|
91
|
+
old_copy.add_bundler_group BundlerGroup.find_or_create(name: 'a')
|
|
92
|
+
old_copy.add_bundler_group BundlerGroup.find_or_create(name: 'b')
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "ensures the correct bundler groups are associated" do
|
|
96
|
+
subject.bundler_groups.map(&:name).should =~ %w[1 2 3]
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
context "license changes to something other than 'other'" do
|
|
101
|
+
before do
|
|
102
|
+
old_copy.license = LicenseAlias.create(name: 'other')
|
|
103
|
+
old_copy.save
|
|
104
|
+
gemspec.license = "new license"
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
context "new license is whitelisted" do
|
|
108
|
+
before { LicenseFinder.config.stub(:whitelist).and_return [gemspec.license] }
|
|
109
|
+
|
|
110
|
+
it "should set the approval to true" do
|
|
111
|
+
subject.should be_approved
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
context "new license is not whitelisted" do
|
|
116
|
+
it "should set the approval to false" do
|
|
117
|
+
subject.should_not be_approved
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
context "license changes to unknown (i.e., 'other')" do
|
|
123
|
+
before do
|
|
124
|
+
old_copy.license = LicenseAlias.create(name: 'MIT')
|
|
125
|
+
old_copy.approval = Approval.create(state: false)
|
|
126
|
+
old_copy.save
|
|
127
|
+
gemspec.license = "other"
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it "should not change the license" do
|
|
131
|
+
subject.license.name.should == 'MIT'
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "should not change the approval" do
|
|
135
|
+
subject.should_not be_approved
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
context "license does not change" do
|
|
140
|
+
before do
|
|
141
|
+
old_copy.license = LicenseAlias.create(name: 'MIT')
|
|
142
|
+
old_copy.approval = Approval.create(state: false)
|
|
143
|
+
old_copy.save
|
|
144
|
+
gemspec.license = "MIT"
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it "should not change the license or approval" do
|
|
148
|
+
subject.should_not be_approved
|
|
149
|
+
subject.license.name.should == "MIT"
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "capybara"
|
|
3
|
+
|
|
4
|
+
module LicenseFinder
|
|
5
|
+
describe HtmlReport do
|
|
6
|
+
describe "#to_s" do
|
|
7
|
+
let(:dependency) do
|
|
8
|
+
dep = Dependency.new name: "the-name"
|
|
9
|
+
dep.license = LicenseAlias.create name: 'MIT'
|
|
10
|
+
dep.approval = Approval.create state: true
|
|
11
|
+
dep
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
subject { Capybara.string(HtmlReport.new([dependency]).to_s) }
|
|
15
|
+
|
|
16
|
+
context "when the dependency is approved" do
|
|
17
|
+
it "should add an approved class to dependency's container" do
|
|
18
|
+
should have_selector ".approved"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "does not list the dependency in the action items" do
|
|
22
|
+
should_not have_selector ".action-items"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
context "when the dependency is not approved" do
|
|
27
|
+
before { dependency.approval.state = false }
|
|
28
|
+
|
|
29
|
+
it "should not add an approved class to he dependency's container" do
|
|
30
|
+
should have_selector ".unapproved"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "lists the dependency in the action items" do
|
|
34
|
+
should have_selector ".action-items li"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "when the gem has at least one bundler group" do
|
|
39
|
+
before { dependency.stub(bundler_groups: [stub(name: "group")]) }
|
|
40
|
+
it "should show the bundler group(s) in parens" do
|
|
41
|
+
should have_text "(group)"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "when the gem has no bundler groups" do
|
|
46
|
+
before { dependency.stub(bundler_groups: []) }
|
|
47
|
+
|
|
48
|
+
it "should not show any parens or bundler group info" do
|
|
49
|
+
should_not have_text "()"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context "when the gem has at least one parent" do
|
|
55
|
+
before { dependency.stub(parents: [stub(:name => "foo parent")]) }
|
|
56
|
+
it "should include a parents section" do
|
|
57
|
+
should have_text "Parents"
|
|
58
|
+
should have_text "foo parent"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
context "when the gem has no parents" do
|
|
63
|
+
it "should not include any parents section in the output" do
|
|
64
|
+
should_not have_text "Parents"
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context "when the gem has at least one child" do
|
|
69
|
+
before { dependency.stub(children: [stub(:name => "foo child")]) }
|
|
70
|
+
|
|
71
|
+
it "should include a Children section" do
|
|
72
|
+
should have_text "Children"
|
|
73
|
+
should have_text "foo child"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
context "when the gem has no children" do
|
|
78
|
+
it "should not include any Children section in the output" do
|
|
79
|
+
should_not have_text "Children"
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe LicenseFinder::License::BSD do
|
|
4
|
+
subject { LicenseFinder::License::BSD.new("") }
|
|
5
|
+
|
|
6
|
+
it_behaves_like "a license matcher"
|
|
7
|
+
|
|
8
|
+
it "should match regardless of organization or copyright holder names or quotes" do
|
|
9
|
+
license = LicenseFinder::License::BSD.new <<-LICENSE
|
|
10
|
+
Copyright (c) 2000, Widgets, Inc.
|
|
11
|
+
All rights reserved.
|
|
12
|
+
|
|
13
|
+
Redistribution and use in source and binary forms, with or without
|
|
14
|
+
modification, are permitted provided that the following conditions are met:
|
|
15
|
+
1. Redistributions of source code must retain the above copyright
|
|
16
|
+
notice, this list of conditions and the following disclaimer.
|
|
17
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
18
|
+
notice, this list of conditions and the following disclaimer in the
|
|
19
|
+
documentation and/or other materials provided with the distribution.
|
|
20
|
+
3. All advertising materials mentioning features or use of this software
|
|
21
|
+
must display the following acknowledgement:
|
|
22
|
+
This product includes software developed by <organization>.
|
|
23
|
+
4. Neither the name of foo bar *%*%*%*% nor the
|
|
24
|
+
names of its contributors may be used to endorse or promote products
|
|
25
|
+
derived from this software without specific prior written permission.
|
|
26
|
+
|
|
27
|
+
THIS SOFTWARE IS PROVIDED BY awesome *$*$* copyright name 'AS IS' AND ANY
|
|
28
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
29
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
30
|
+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
31
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
32
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
33
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
34
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
35
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
36
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37
|
+
LICENSE
|
|
38
|
+
|
|
39
|
+
license.should be_matches
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe LicenseFinder::License::MIT do
|
|
4
|
+
subject { LicenseFinder::License::MIT.new("") }
|
|
5
|
+
|
|
6
|
+
it_behaves_like "a license matcher"
|
|
7
|
+
|
|
8
|
+
describe "#matches?" do
|
|
9
|
+
it "should return true if the text contains the MIT url" do
|
|
10
|
+
subject.text = "MIT License is awesome http://opensource.org/licenses/mit-license"
|
|
11
|
+
should be_matches
|
|
12
|
+
|
|
13
|
+
subject.text = "MIT Licence is awesome http://www.opensource.org/licenses/mit-license"
|
|
14
|
+
should be_matches
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should return true if the text contains 'The MIT License'" do
|
|
18
|
+
subject.text = "The MIT License"
|
|
19
|
+
should be_matches
|
|
20
|
+
|
|
21
|
+
subject.text = "The MIT Licence"
|
|
22
|
+
should be_matches
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should return true if the text contains 'is released under the MIT license'" do
|
|
26
|
+
subject.text = "is released under the MIT license"
|
|
27
|
+
should be_matches
|
|
28
|
+
|
|
29
|
+
subject.text = "is released under the MIT licence"
|
|
30
|
+
should be_matches
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|