license_finder 0.4.5 → 0.5.0
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/README.markdown +43 -11
- data/bin/license_finder +2 -5
- data/features/executables/license_finder.feature +19 -0
- data/features/rake_tasks/action_items.feature +18 -4
- data/features/rake_tasks/action_items_ok.feature +10 -7
- data/features/rake_tasks/generate_dependencies.feature +43 -12
- data/features/rake_tasks/init.feature +8 -1
- data/features/rake_tasks/regressions.feature +18 -0
- data/features/step_definitions/steps.rb +163 -43
- data/lib/license_finder.rb +9 -4
- data/lib/license_finder/{gem_spec_details.rb → bundled_gem.rb} +12 -41
- data/lib/license_finder/bundler_dependency_query.rb +51 -0
- data/lib/license_finder/cli.rb +16 -0
- data/lib/license_finder/dependency.rb +80 -28
- data/lib/license_finder/dependency_list.rb +20 -35
- data/lib/license_finder/finder.rb +2 -2
- data/lib/license_finder/license.rb +74 -0
- data/lib/license_finder/license/apache.rb +5 -0
- data/lib/license_finder/license/bsd.rb +2 -0
- data/lib/license_finder/license/gplv2.rb +2 -0
- data/lib/license_finder/license/isc.rb +2 -0
- data/lib/license_finder/license/lgpl.rb +2 -0
- data/lib/license_finder/license/mit.rb +20 -0
- data/lib/license_finder/license/new_bsd.rb +5 -0
- data/lib/license_finder/license/ruby.rb +11 -0
- data/lib/license_finder/license/simplified_bsd.rb +5 -0
- data/lib/license_finder/{file_parser.rb → possible_license_file.rb} +9 -17
- data/lib/tasks/license_finder.rake +8 -8
- data/lib/templates/{Apache-2.0-body → Apache.txt} +0 -0
- data/lib/templates/BSD.txt +24 -0
- data/lib/templates/{GPL-2.0-body → GPLv2.txt} +0 -0
- data/lib/templates/{ISC-body → ISC.txt} +0 -0
- data/lib/templates/{LGPL-body → LGPL.txt} +0 -0
- data/lib/templates/{MIT-body → MIT.txt} +0 -0
- data/lib/templates/NewBSD.txt +21 -0
- data/lib/templates/Ruby.txt +52 -0
- data/lib/templates/SimplifiedBSD.txt +23 -0
- data/license_finder.gemspec +4 -3
- data/spec/fixtures/{no_license/.gitkeep → license_names/Licence.rdoc} +0 -0
- data/spec/lib/license_finder/bundled_gem_spec.rb +148 -0
- data/spec/lib/license_finder/dependency_list_spec.rb +133 -144
- data/spec/lib/license_finder/dependency_spec.rb +189 -5
- 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/possible_license_file_spec.rb +42 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/support/license_examples.rb +24 -0
- metadata +89 -33
- data/lib/license_finder/license_file.rb +0 -98
- data/spec/fixtures/apache_licensed_gem/LICENSE +0 -191
- data/spec/fixtures/gplv2_licensed_gem/LICENSE +0 -339
- data/spec/fixtures/isc_licensed_gem/LICENSE +0 -10
- data/spec/fixtures/lgpl_licensed_gem/LICENSE +0 -165
- data/spec/fixtures/mit_licensed_gem_in_README/README.rdoc +0 -222
- data/spec/fixtures/mit_licensed_gem_via_url/README +0 -210
- data/spec/fixtures/mit_licensed_with_hashes/MIT-LICENSE +0 -20
- data/spec/lib/license_finder/file_parser_spec.rb +0 -16
- data/spec/lib/license_finder/gem_spec_details_spec.rb +0 -229
- data/spec/lib/license_finder/license_file_spec.rb +0 -155
@@ -0,0 +1,20 @@
|
|
1
|
+
class LicenseFinder::License::MIT < LicenseFinder::License::Base
|
2
|
+
HEADER_REGEX = /The MIT Licen[sc]e/
|
3
|
+
ONE_LINER_REGEX = /is released under the MIT licen[sc]e/
|
4
|
+
URL_REGEX = %r{MIT Licen[sc]e.*http://www.opensource.org/licenses/mit-license}
|
5
|
+
|
6
|
+
def matches?
|
7
|
+
super || matches_url? || matches_header?
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def matches_url?
|
13
|
+
!!(text =~ URL_REGEX)
|
14
|
+
end
|
15
|
+
|
16
|
+
def matches_header?
|
17
|
+
header = text.split("\n").first
|
18
|
+
header && ((header.strip =~ HEADER_REGEX) || !!(text =~ ONE_LINER_REGEX))
|
19
|
+
end
|
20
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module LicenseFinder
|
2
|
-
class
|
2
|
+
class PossibleLicenseFile
|
3
3
|
def initialize(install_path, file_path)
|
4
4
|
@install_path = Pathname.new(install_path)
|
5
5
|
@file_path = Pathname.new(file_path)
|
@@ -18,23 +18,15 @@ module LicenseFinder
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def text
|
21
|
-
@text ||= @file_path.send(
|
21
|
+
@text ||= @file_path.send(@file_path.respond_to?(:binread) ? :binread : :read)
|
22
22
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def without_punctuation(text)
|
33
|
-
text.gsub('#', '').gsub(' ', '')
|
34
|
-
end
|
35
|
-
|
36
|
-
def cleaned_up(text)
|
37
|
-
without_punctuation(on_single_line(text))
|
23
|
+
|
24
|
+
def license
|
25
|
+
license = LicenseFinder::License.all.detect do |klass|
|
26
|
+
klass.new(text).matches?
|
27
|
+
end
|
28
|
+
|
29
|
+
license && license.pretty_name
|
38
30
|
end
|
39
31
|
end
|
40
32
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
namespace :license do
|
2
2
|
desc 'write out example config file'
|
3
3
|
task :init do
|
4
|
+
`mkdir -p ./config`
|
4
5
|
FileUtils.cp(File.join(File.dirname(__FILE__), '..', '..', 'files', 'license_finder.yml'), './config/license_finder.yml')
|
5
6
|
end
|
6
7
|
|
@@ -11,19 +12,18 @@ namespace :license do
|
|
11
12
|
|
12
13
|
desc 'action items'
|
13
14
|
task :action_items => :generate_dependencies do
|
14
|
-
|
15
|
-
puts LicenseFinder::Finder.new.action_items
|
15
|
+
LicenseFinder::CLI.new.check_for_action_items
|
16
16
|
end
|
17
17
|
|
18
|
-
desc '
|
18
|
+
desc 'return a failure status code for unapproved dependencies'
|
19
19
|
task 'action_items:ok' => :generate_dependencies do
|
20
|
+
puts "rake license:action_items:ok is deprecated and will be removed in version 1.0. Use rake license:action_items instead."
|
21
|
+
|
20
22
|
found = LicenseFinder::Finder.new.action_items
|
21
|
-
if found.size
|
22
|
-
puts "Dependencies that need approval:"
|
23
|
-
puts found
|
24
|
-
else
|
23
|
+
if found.size == 0
|
25
24
|
puts "All gems are approved for use"
|
25
|
+
else
|
26
|
+
exit 1
|
26
27
|
end
|
27
|
-
exit 1 unless found.size == 0
|
28
28
|
end
|
29
29
|
end
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Redistribution and use in source and binary forms, with or without
|
2
|
+
modification, are permitted provided that the following conditions are met:
|
3
|
+
1. Redistributions of source code must retain the above copyright
|
4
|
+
notice, this list of conditions and the following disclaimer.
|
5
|
+
2. Redistributions in binary form must reproduce the above copyright
|
6
|
+
notice, this list of conditions and the following disclaimer in the
|
7
|
+
documentation and/or other materials provided with the distribution.
|
8
|
+
3. All advertising materials mentioning features or use of this software
|
9
|
+
must display the following acknowledgement:
|
10
|
+
This product includes software developed by <organization>.
|
11
|
+
4. Neither the name of <organization> nor the
|
12
|
+
names of its contributors may be used to endorse or promote products
|
13
|
+
derived from this software without specific prior written permission.
|
14
|
+
|
15
|
+
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
|
16
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Redistribution and use in source and binary forms, with or without
|
2
|
+
modification, are permitted provided that the following conditions are met:
|
3
|
+
* Redistributions of source code must retain the above copyright
|
4
|
+
notice, this list of conditions and the following disclaimer.
|
5
|
+
* Redistributions in binary form must reproduce the above copyright
|
6
|
+
notice, this list of conditions and the following disclaimer in the
|
7
|
+
documentation and/or other materials provided with the distribution.
|
8
|
+
* Neither the name of <organization> nor the
|
9
|
+
names of its contributors may be used to endorse or promote products
|
10
|
+
derived from this software without specific prior written permission.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
13
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
14
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15
|
+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
16
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
17
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
18
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
19
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
20
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
21
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -0,0 +1,52 @@
|
|
1
|
+
1. You may make and give away verbatim copies of the source form of the
|
2
|
+
software without restriction, provided that you duplicate all of the
|
3
|
+
original copyright notices and associated disclaimers.
|
4
|
+
|
5
|
+
2. You may modify your copy of the software in any way, provided that
|
6
|
+
you do at least ONE of the following:
|
7
|
+
|
8
|
+
a) place your modifications in the Public Domain or otherwise
|
9
|
+
make them Freely Available, such as by posting said
|
10
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
11
|
+
the author to include your modifications in the software.
|
12
|
+
|
13
|
+
b) use the modified software only within your corporation or
|
14
|
+
organization.
|
15
|
+
|
16
|
+
c) give non-standard binaries non-standard names, with
|
17
|
+
instructions on where to get the original software distribution.
|
18
|
+
|
19
|
+
d) make other distribution arrangements with the author.
|
20
|
+
|
21
|
+
3. You may distribute the software in object code or binary form,
|
22
|
+
provided that you do at least ONE of the following:
|
23
|
+
|
24
|
+
a) distribute the binaries and library files of the software,
|
25
|
+
together with instructions (in the manual page or equivalent)
|
26
|
+
on where to get the original distribution.
|
27
|
+
|
28
|
+
b) accompany the distribution with the machine-readable source of
|
29
|
+
the software.
|
30
|
+
|
31
|
+
c) give non-standard binaries non-standard names, with
|
32
|
+
instructions on where to get the original software distribution.
|
33
|
+
|
34
|
+
d) make other distribution arrangements with the author.
|
35
|
+
|
36
|
+
4. You may modify and include the part of the software into any other
|
37
|
+
software (possibly commercial). But some files in the distribution
|
38
|
+
are not written by the author, so that they are not under these terms.
|
39
|
+
|
40
|
+
For the list of those files and their copying conditions, see the
|
41
|
+
file LEGAL.
|
42
|
+
|
43
|
+
5. The scripts and library files supplied as input to or produced as
|
44
|
+
output from the software do not automatically fall under the
|
45
|
+
copyright of the software, but belong to whomever generated them,
|
46
|
+
and may be sold commercially, and may be aggregated with this
|
47
|
+
software.
|
48
|
+
|
49
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
50
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
51
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
52
|
+
PURPOSE.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Redistribution and use in source and binary forms, with or without
|
2
|
+
modification, are permitted provided that the following conditions are met:
|
3
|
+
|
4
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
5
|
+
list of conditions and the following disclaimer.
|
6
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
7
|
+
this list of conditions and the following disclaimer in the documentation
|
8
|
+
and/or other materials provided with the distribution.
|
9
|
+
|
10
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
11
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
12
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
13
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
14
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
15
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
16
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
17
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
18
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
19
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20
|
+
|
21
|
+
The views and conclusions contained in the software and documentation are those
|
22
|
+
of the authors and should not be interpreted as representing official policies,
|
23
|
+
either expressed or implied, of the FreeBSD Project.
|
data/license_finder.gemspec
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "license_finder"
|
3
|
-
s.version = "0.
|
4
|
-
s.authors = ["Jacob Maine", "Matthew Kane Parker", "Ian Lesperance", "David Edwards"]
|
3
|
+
s.version = "0.5.0"
|
4
|
+
s.authors = ["Jacob Maine", "Matthew Kane Parker", "Ian Lesperance", "David Edwards", "Paul Meskers"]
|
5
5
|
s.email = ["brent@pivotalabs.com"]
|
6
6
|
s.homepage = "https://github.com/pivotal/LicenseFinder"
|
7
7
|
s.summary = "Know your dependencies - and the licenses they are binding your application to."
|
8
8
|
s.description = "Find and display licenses of a project's gem dependencies, so that you know what your limitations are when distributing your application."
|
9
9
|
s.license = "MIT"
|
10
10
|
|
11
|
+
s.add_dependency "bundler"
|
11
12
|
s.add_development_dependency "rails", ">=3"
|
12
|
-
%w(rspec rr rake cucumber rails).each do |gem|
|
13
|
+
%w(rspec rr rake cucumber rails pry).each do |gem|
|
13
14
|
s.add_development_dependency gem
|
14
15
|
end
|
15
16
|
|
File without changes
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LicenseFinder::BundledGem do
|
4
|
+
subject { LicenseFinder::BundledGem.new(gemspec) }
|
5
|
+
|
6
|
+
let(:gemspec) do
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'spec_name'
|
9
|
+
s.version = '2.1.3'
|
10
|
+
s.summary = 'summary'
|
11
|
+
s.description = 'description'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def fixture_path(fixture)
|
16
|
+
File.realpath(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec', 'fixtures', fixture))
|
17
|
+
end
|
18
|
+
|
19
|
+
its(:name) { should == 'spec_name 2.1.3' }
|
20
|
+
its(:dependency_name) { should == 'spec_name' }
|
21
|
+
its(:dependency_version) { should == '2.1.3' }
|
22
|
+
its(:install_path) { should == gemspec.full_gem_path }
|
23
|
+
|
24
|
+
describe "#determine_license" do
|
25
|
+
subject do
|
26
|
+
details = LicenseFinder::BundledGem.new(gemspec)
|
27
|
+
stub(details).license_files { [license_file] }
|
28
|
+
details
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:license_file) { LicenseFinder::PossibleLicenseFile.new('gem', 'gem/license/path') }
|
32
|
+
|
33
|
+
it "returns the license from the gemspec if provided" do
|
34
|
+
stub(gemspec).license { "Some License" }
|
35
|
+
|
36
|
+
subject.determine_license.should == "Some License"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns the matched license if detected" do
|
40
|
+
stub(license_file).license { "Detected License" }
|
41
|
+
|
42
|
+
subject.determine_license.should == "Detected License"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "returns 'other' otherwise" do
|
46
|
+
stub(license_file).license { nil }
|
47
|
+
|
48
|
+
subject.determine_license.should == "other"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#license_files" do
|
53
|
+
it "is empty if there aren't any license files" do
|
54
|
+
subject.license_files.should == []
|
55
|
+
end
|
56
|
+
|
57
|
+
it "includes files with names like LICENSE, License or COPYING" do
|
58
|
+
stub(gemspec).full_gem_path { fixture_path('license_names') }
|
59
|
+
|
60
|
+
subject.license_files.map(&:file_name).should =~
|
61
|
+
%w[COPYING.txt LICENSE Mit-License README.rdoc Licence.rdoc]
|
62
|
+
end
|
63
|
+
|
64
|
+
it "includes files deep in the hierarchy" do
|
65
|
+
stub(gemspec).full_gem_path { fixture_path('nested_gem') }
|
66
|
+
|
67
|
+
subject.license_files.map { |f| [f.file_name, f.file_path] }.should =~ [
|
68
|
+
%w[LICENSE vendor/LICENSE]
|
69
|
+
]
|
70
|
+
end
|
71
|
+
|
72
|
+
it "includes both files nested inside LICENSE directory and top level files" do
|
73
|
+
stub(gemspec).full_gem_path { fixture_path('license_directory') }
|
74
|
+
found_license_files = subject.license_files
|
75
|
+
|
76
|
+
found_license_files.map { |f| [f.file_name, f.file_path] }.should =~ [
|
77
|
+
%w[BSD-2-Clause.txt LICENSE/BSD-2-Clause.txt],
|
78
|
+
%w[GPL-2.0.txt LICENSE/GPL-2.0.txt],
|
79
|
+
%w[MIT.txt LICENSE/MIT.txt],
|
80
|
+
%w[RUBY.txt LICENSE/RUBY.txt],
|
81
|
+
%w[COPYING COPYING],
|
82
|
+
%w[LICENSE LICENSE/LICENSE]
|
83
|
+
]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "#readme_files" do
|
88
|
+
it "is empty if there aren't any readme files" do
|
89
|
+
subject.readme_files.should == []
|
90
|
+
end
|
91
|
+
|
92
|
+
it "includes files with names like README, Readme or COPYING" do
|
93
|
+
stub(gemspec).full_gem_path { fixture_path('readme') }
|
94
|
+
|
95
|
+
subject.readme_files.map(&:file_name).should =~ [
|
96
|
+
"Project ReadMe",
|
97
|
+
"README",
|
98
|
+
"Readme.markdown"
|
99
|
+
]
|
100
|
+
end
|
101
|
+
|
102
|
+
it "includes files deep in the hierarchy" do
|
103
|
+
stub(gemspec).full_gem_path { fixture_path('nested_readme') }
|
104
|
+
|
105
|
+
subject.readme_files.map { |f| [f.file_name, f.file_path] }.should =~ [
|
106
|
+
%w[README vendor/README]
|
107
|
+
]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#dependency' do
|
112
|
+
subject { LicenseFinder::BundledGem.new(gemspec).dependency }
|
113
|
+
|
114
|
+
its(:name) { should == 'spec_name' }
|
115
|
+
its(:version) { should == '2.1.3' }
|
116
|
+
its(:summary) { should == 'summary' }
|
117
|
+
its(:source) { should == 'bundle' }
|
118
|
+
its(:description) { should == 'description' }
|
119
|
+
|
120
|
+
describe 'with a known license' do
|
121
|
+
before do
|
122
|
+
stub(gemspec).full_gem_path { fixture_path('mit_licensed_gem') }
|
123
|
+
any_instance_of(LicenseFinder::PossibleLicenseFile, :license => 'Detected License')
|
124
|
+
end
|
125
|
+
|
126
|
+
its(:license) { should == 'Detected License' }
|
127
|
+
end
|
128
|
+
|
129
|
+
describe 'with an unknown license' do
|
130
|
+
before do
|
131
|
+
stub(gemspec).full_gem_path { fixture_path('other_licensed_gem') }
|
132
|
+
any_instance_of(LicenseFinder::PossibleLicenseFile, :license => nil)
|
133
|
+
end
|
134
|
+
|
135
|
+
its(:license) { should == 'other' }
|
136
|
+
end
|
137
|
+
|
138
|
+
describe 'with UTF8 file License' do
|
139
|
+
before do
|
140
|
+
stub(gemspec).full_gem_path { fixture_path('utf8_gem') }
|
141
|
+
end
|
142
|
+
|
143
|
+
it "handles non UTF8 encodings" do
|
144
|
+
expect { subject }.not_to raise_error ArgumentError, "invalid byte sequence in UTF-8"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|