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
@@ -1,20 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010, 2011 Matthew Kocher
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
# a copy of this software and associated documentation files (the
|
5
|
-
# "Software"), to deal in the Software without restriction, including
|
6
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
# the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be
|
12
|
-
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe LicenseFinder::FileParser do
|
4
|
-
subject { LicenseFinder::FileParser.new('root', 'root/nested/path') }
|
5
|
-
|
6
|
-
context "ignoring text" do
|
7
|
-
before do
|
8
|
-
stub(IO).read { "file text" }
|
9
|
-
stub(IO).binread { "file text" }
|
10
|
-
end
|
11
|
-
|
12
|
-
its(:file_path) { should == 'nested/path' }
|
13
|
-
its(:file_name) { should == 'path' }
|
14
|
-
its(:text) { should == 'file text' }
|
15
|
-
end
|
16
|
-
end
|
@@ -1,229 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe LicenseFinder::GemSpecDetails do
|
4
|
-
before do
|
5
|
-
@mock_gemspec = Class.new do
|
6
|
-
def initialize(path = nil)
|
7
|
-
@path = path
|
8
|
-
end
|
9
|
-
|
10
|
-
def name
|
11
|
-
'spec_name'
|
12
|
-
end
|
13
|
-
|
14
|
-
def version
|
15
|
-
'2.1.3'
|
16
|
-
end
|
17
|
-
|
18
|
-
def full_gem_path
|
19
|
-
if @path
|
20
|
-
gem_install_path = File.join(File.dirname(__FILE__), '..', '..', '..', @path)
|
21
|
-
raise Errno::ENOENT, @path unless File.exists?(gem_install_path)
|
22
|
-
gem_install_path
|
23
|
-
else
|
24
|
-
'install/path'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def license
|
29
|
-
nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
subject { LicenseFinder::GemSpecDetails.new(@mock_gemspec.new) }
|
35
|
-
|
36
|
-
its(:name) { should == 'spec_name 2.1.3' }
|
37
|
-
its(:dependency_name) { should == 'spec_name' }
|
38
|
-
its(:dependency_version) { should == '2.1.3' }
|
39
|
-
its(:install_path) { should == 'install/path' }
|
40
|
-
|
41
|
-
describe "#gemspec licenses" do
|
42
|
-
it "returns the license from the gemspec if provided" do
|
43
|
-
mock_gemspec = @mock_gemspec.new
|
44
|
-
stub(mock_gemspec).license { "MIT" }
|
45
|
-
LicenseFinder::GemSpecDetails.new(mock_gemspec).determine_license.should == "MIT"
|
46
|
-
end
|
47
|
-
|
48
|
-
it "returns 'ruby' if if is a ruby license" do
|
49
|
-
mock_gemspec = @mock_gemspec.new
|
50
|
-
mock_license_file = LicenseFinder::LicenseFile.new('gem', 'gem/license/path')
|
51
|
-
stub(mock_license_file).mit_license_body? { false }
|
52
|
-
stub(mock_license_file).mit_license_header? { false }
|
53
|
-
stub(mock_license_file).apache_license_body? { false }
|
54
|
-
stub(mock_license_file).gplv2_license_body? { false }
|
55
|
-
|
56
|
-
stub(mock_license_file).ruby_license_body? { true }
|
57
|
-
|
58
|
-
|
59
|
-
gemspec_details = LicenseFinder::GemSpecDetails.new(mock_gemspec)
|
60
|
-
stub(gemspec_details).license_files { [ mock_license_file ] }
|
61
|
-
|
62
|
-
gemspec_details.determine_license.should == "ruby"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "#license_files" do
|
67
|
-
it "is empty if there aren't any license files" do
|
68
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new).license_files.should == []
|
69
|
-
end
|
70
|
-
|
71
|
-
it "includes files with names like LICENSE, License or COPYING" do
|
72
|
-
gem_spec = @mock_gemspec.new('spec/fixtures/license_names')
|
73
|
-
LicenseFinder::GemSpecDetails.new(gem_spec).license_files.map(&:file_name).should =~
|
74
|
-
%w[COPYING.txt LICENSE Mit-License README.rdoc]
|
75
|
-
end
|
76
|
-
|
77
|
-
it "includes files deep in the hierarchy" do
|
78
|
-
gem_spec = @mock_gemspec.new('spec/fixtures/nested_gem')
|
79
|
-
LicenseFinder::GemSpecDetails.new(gem_spec).license_files.map { |f| [f.file_name, f.file_path] }.should =~
|
80
|
-
[['LICENSE', 'vendor/LICENSE']]
|
81
|
-
end
|
82
|
-
|
83
|
-
it "includes both files nested inside LICENSE directory and top level files" do
|
84
|
-
gem_spec = @mock_gemspec.new('spec/fixtures/license_directory')
|
85
|
-
found_license_files = LicenseFinder::GemSpecDetails.new(gem_spec).license_files
|
86
|
-
found_license_files.map(&:file_name).should =~
|
87
|
-
%w[BSD-2-Clause.txt GPL-2.0.txt MIT.txt RUBY.txt COPYING LICENSE]
|
88
|
-
found_license_files.map(&:file_path).should =~
|
89
|
-
%w[LICENSE/BSD-2-Clause.txt LICENSE/GPL-2.0.txt LICENSE/MIT.txt LICENSE/RUBY.txt COPYING LICENSE/LICENSE]
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
describe "#readme_files" do
|
96
|
-
it "is empty if there aren't any readme files" do
|
97
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new).readme_files.should == []
|
98
|
-
end
|
99
|
-
|
100
|
-
it "includes files with names like README, Readme or COPYING" do
|
101
|
-
gem_spec = @mock_gemspec.new('spec/fixtures/readme')
|
102
|
-
LicenseFinder::GemSpecDetails.new(gem_spec).readme_files.map(&:file_name).should =~
|
103
|
-
%w[Project\ ReadMe README Readme.markdown]
|
104
|
-
end
|
105
|
-
|
106
|
-
it "includes files deep in the hierarchy" do
|
107
|
-
gem_spec = @mock_gemspec.new('spec/fixtures/nested_readme')
|
108
|
-
LicenseFinder::GemSpecDetails.new(gem_spec).readme_files.map { |f| [f.file_name, f.file_path] }.should =~
|
109
|
-
[['README', 'vendor/README']]
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
describe 'to dependency' do
|
114
|
-
before do
|
115
|
-
stub(LicenseFinder).config.stub!.whitelist { ['MIT', 'Apache 2.0', 'LGPL', 'GPLv2'] }
|
116
|
-
end
|
117
|
-
|
118
|
-
describe 'with MIT License' do
|
119
|
-
subject do
|
120
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_gem')).dependency
|
121
|
-
end
|
122
|
-
|
123
|
-
its(:name) { should == 'spec_name' }
|
124
|
-
its(:version) { should == '2.1.3' }
|
125
|
-
its(:license) { should == 'MIT' }
|
126
|
-
its(:approved) { should == true }
|
127
|
-
its(:license_url) { should == '' }
|
128
|
-
its(:notes) { should == '' }
|
129
|
-
end
|
130
|
-
|
131
|
-
describe 'with MIT License in README' do
|
132
|
-
subject do
|
133
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_gem_in_README')).dependency
|
134
|
-
end
|
135
|
-
|
136
|
-
its(:name) { should == 'spec_name' }
|
137
|
-
its(:version) { should == '2.1.3' }
|
138
|
-
its(:license) { should == 'MIT' }
|
139
|
-
its(:approved) { should == true }
|
140
|
-
its(:license_url) { should == '' }
|
141
|
-
its(:notes) { should == '' }
|
142
|
-
end
|
143
|
-
|
144
|
-
describe 'with MIT License in README' do
|
145
|
-
subject do
|
146
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_gem_via_url')).dependency
|
147
|
-
end
|
148
|
-
|
149
|
-
its(:name) { should == 'spec_name' }
|
150
|
-
its(:version) { should == '2.1.3' }
|
151
|
-
its(:license) { should == 'MIT' }
|
152
|
-
its(:approved) { should == true }
|
153
|
-
its(:license_url) { should == '' }
|
154
|
-
its(:notes) { should == '' }
|
155
|
-
end
|
156
|
-
|
157
|
-
describe 'with MIT License with hashes' do
|
158
|
-
subject do
|
159
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_with_hashes')).dependency
|
160
|
-
end
|
161
|
-
|
162
|
-
its(:name) { should == 'spec_name' }
|
163
|
-
its(:version) { should == '2.1.3' }
|
164
|
-
its(:license) { should == 'MIT' }
|
165
|
-
its(:approved) { should == true }
|
166
|
-
its(:license_url) { should == '' }
|
167
|
-
its(:notes) { should == '' }
|
168
|
-
end
|
169
|
-
|
170
|
-
describe 'with Apache License' do
|
171
|
-
subject do
|
172
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/apache_licensed_gem')).dependency
|
173
|
-
end
|
174
|
-
|
175
|
-
its(:name) { should == 'spec_name' }
|
176
|
-
its(:version) { should == '2.1.3' }
|
177
|
-
its(:license) { should == 'Apache 2.0' }
|
178
|
-
its(:approved) { should == true }
|
179
|
-
its(:license_url) { should == '' }
|
180
|
-
its(:notes) { should == '' }
|
181
|
-
end
|
182
|
-
|
183
|
-
describe 'with GPLv2 License' do
|
184
|
-
subject do
|
185
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/gplv2_licensed_gem')).dependency
|
186
|
-
end
|
187
|
-
|
188
|
-
its(:name) { should == 'spec_name' }
|
189
|
-
its(:version) { should == '2.1.3' }
|
190
|
-
its(:license) { should == 'GPLv2' }
|
191
|
-
its(:approved) { should == true }
|
192
|
-
its(:license_url) { should == '' }
|
193
|
-
its(:notes) { should == '' }
|
194
|
-
end
|
195
|
-
|
196
|
-
describe 'with LGPL License' do
|
197
|
-
it "should detect the license as LGPL" do
|
198
|
-
dependency = LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/lgpl_licensed_gem')).dependency
|
199
|
-
dependency.license.should == "LGPL"
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
describe 'with ISC License' do
|
204
|
-
it "should detect the license as ISC" do
|
205
|
-
dependency = LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/isc_licensed_gem')).dependency
|
206
|
-
dependency.license.should == "ISC"
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
describe 'with unknown license' do
|
211
|
-
subject { LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/other_licensed_gem')).dependency }
|
212
|
-
|
213
|
-
its(:name) { should == 'spec_name' }
|
214
|
-
its(:version) { should == '2.1.3' }
|
215
|
-
its(:license) { should == 'other' }
|
216
|
-
its(:approved) { should == false }
|
217
|
-
its(:license_url) { should == '' }
|
218
|
-
its(:notes) { should == '' }
|
219
|
-
end
|
220
|
-
|
221
|
-
describe 'with UTF8 file License' do
|
222
|
-
it "handles non UTF8 encodings" do
|
223
|
-
expect do
|
224
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/utf8_gem')).dependency
|
225
|
-
end.not_to raise_error ArgumentError, "invalid byte sequence in UTF-8"
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
@@ -1,155 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe LicenseFinder::LicenseFile do
|
4
|
-
subject { LicenseFinder::LicenseFile.new('gem', 'gem/license/path') }
|
5
|
-
|
6
|
-
context "ignoring text" do
|
7
|
-
before do
|
8
|
-
stub(IO).read { "file text" }
|
9
|
-
stub(IO).binread { "file text" }
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#to_hash" do
|
13
|
-
it "includes file path" do
|
14
|
-
subject.to_hash['file_name'].should == 'license/path'
|
15
|
-
end
|
16
|
-
|
17
|
-
it "does not include file text by default" do
|
18
|
-
subject.to_hash['text'].should be_nil
|
19
|
-
end
|
20
|
-
|
21
|
-
it "includes file text if requested" do
|
22
|
-
subject.include_license_text = true
|
23
|
-
subject.to_hash['text'].should == 'file text'
|
24
|
-
end
|
25
|
-
|
26
|
-
it "includes data about license" do
|
27
|
-
subject.to_hash.should have_key 'body_type'
|
28
|
-
subject.to_hash.should have_key 'header_type'
|
29
|
-
subject.to_hash.should have_key 'disclaimer_of_liability'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "with MIT like license" do
|
35
|
-
before do
|
36
|
-
stub(IO).read { File.read(File.join(File.dirname(__FILE__), '../../fixtures/MIT-LICENSE')) }
|
37
|
-
stub(IO).binread { File.read(File.join(File.dirname(__FILE__), '../../fixtures/MIT-LICENSE')) }
|
38
|
-
end
|
39
|
-
|
40
|
-
its(:body_type) { should == 'mit' }
|
41
|
-
its(:header_type) { should == 'mit' }
|
42
|
-
its(:disclaimer_of_liability) { should == 'mit: THE AUTHORS OR COPYRIGHT HOLDERS' }
|
43
|
-
end
|
44
|
-
|
45
|
-
context "with MIT reference in README" do
|
46
|
-
before do
|
47
|
-
stub(IO).read { File.read(File.join(File.dirname(__FILE__), '../../fixtures/README-with-MIT-LICENSE')) }
|
48
|
-
stub(IO).binread { File.read(File.join(File.dirname(__FILE__), '../../fixtures/README-with-MIT-LICENSE')) }
|
49
|
-
end
|
50
|
-
|
51
|
-
its(:body_type) { should == 'other' }
|
52
|
-
its(:header_type) { should == 'mit' }
|
53
|
-
its(:disclaimer_of_liability) { should == 'other' }
|
54
|
-
end
|
55
|
-
|
56
|
-
context "with MIT url in README" do
|
57
|
-
before do
|
58
|
-
stub(IO).read { 'MIT Licence (http://www.opensource.org/licenses/mit-license.html)' }
|
59
|
-
stub(IO).binread { 'MIT Licence (http://www.opensource.org/licenses/mit-license.html)' }
|
60
|
-
end
|
61
|
-
|
62
|
-
its(:body_type) { should == 'mit' }
|
63
|
-
its(:disclaimer_of_liability) { should == 'mit: THE AUTHORS OR COPYRIGHT HOLDERS' }
|
64
|
-
end
|
65
|
-
|
66
|
-
context "with ruby url in README" do
|
67
|
-
before do
|
68
|
-
stub(IO).read { "Same as Ruby's \n\nhttp://www.ruby-lang.org/en/LICENSE.txt" }
|
69
|
-
stub(IO).binread { "Same as Ruby's \n\nhttp://www.ruby-lang.org/en/LICENSE.txt" }
|
70
|
-
end
|
71
|
-
|
72
|
-
its(:body_type) { should == 'ruby' }
|
73
|
-
its(:disclaimer_of_liability) { should == 'other' }
|
74
|
-
end
|
75
|
-
|
76
|
-
context "with Apache like license" do
|
77
|
-
before do
|
78
|
-
stub(IO).read { File.read(File.join(File.dirname(__FILE__), '../..//fixtures/APACHE-2-LICENSE')) }
|
79
|
-
stub(IO).binread { File.read(File.join(File.dirname(__FILE__), '../..//fixtures/APACHE-2-LICENSE')) }
|
80
|
-
end
|
81
|
-
|
82
|
-
its(:body_type) { should == 'apache' }
|
83
|
-
end
|
84
|
-
|
85
|
-
context "with GPLv2 like license" do
|
86
|
-
before do
|
87
|
-
stub(IO).read { File.read(File.join(File.dirname(__FILE__), '../..//fixtures/GPLv2')) }
|
88
|
-
stub(IO).binread { File.read(File.join(File.dirname(__FILE__), '../..//fixtures/GPLv2')) }
|
89
|
-
end
|
90
|
-
|
91
|
-
its(:body_type) { should == 'gplv2' }
|
92
|
-
end
|
93
|
-
|
94
|
-
context "with LGPL like license" do
|
95
|
-
before do
|
96
|
-
stub(IO).read { File.read(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'templates', 'LGPL-body')) }
|
97
|
-
stub(IO).binread { File.read(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'templates', 'LGPL-body')) }
|
98
|
-
end
|
99
|
-
|
100
|
-
its(:body_type) { should == 'lgpl' }
|
101
|
-
end
|
102
|
-
|
103
|
-
context "with an ISC license" do
|
104
|
-
before do
|
105
|
-
stub(IO).read { File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'ISC-LICENSE')) }
|
106
|
-
stub(IO).binread { File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'ISC-LICENSE')) }
|
107
|
-
end
|
108
|
-
|
109
|
-
its(:body_type) { should == 'isc' }
|
110
|
-
end
|
111
|
-
|
112
|
-
context "with another license" do
|
113
|
-
before do
|
114
|
-
stub(IO).read { "a non-standard license" }
|
115
|
-
stub(IO).binread { "a non-standard license" }
|
116
|
-
end
|
117
|
-
|
118
|
-
its(:body_type) { should == 'other' }
|
119
|
-
its(:header_type) { should == 'other' }
|
120
|
-
its(:disclaimer_of_liability) { should == 'other' }
|
121
|
-
end
|
122
|
-
|
123
|
-
context "with variation in disclaimer of liability" do
|
124
|
-
before do
|
125
|
-
stub(IO).read { File.read(File.join(File.dirname(__FILE__), '../../../fixtures/MIT-LICENSE-with-varied-disclaimer')) }
|
126
|
-
stub(IO).binread { File.read(File.join(File.dirname(__FILE__), '../../../spec/fixtures/MIT-LICENSE-with-varied-disclaimer')) }
|
127
|
-
end
|
128
|
-
|
129
|
-
its(:body_type) { should == 'mit' }
|
130
|
-
its(:header_type) { should == 'mit' }
|
131
|
-
its(:disclaimer_of_liability) { should == 'mit: THE AUTHORS' }
|
132
|
-
end
|
133
|
-
|
134
|
-
context "with empty license file" do
|
135
|
-
before do
|
136
|
-
stub(IO).read { "" }
|
137
|
-
stub(IO).binread { "" }
|
138
|
-
end
|
139
|
-
|
140
|
-
describe "#to_hash" do
|
141
|
-
it "is safe" do
|
142
|
-
lambda { subject.to_hash }.should_not raise_error
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe "with variations on MIT header" do
|
148
|
-
before do
|
149
|
-
stub(IO).read { '(The MIT License)' }
|
150
|
-
stub(IO).binread { '(The MIT License)' }
|
151
|
-
end
|
152
|
-
|
153
|
-
its(:header_type) { should == 'mit' }
|
154
|
-
end
|
155
|
-
end
|