license_finder 1.0.0.0-java → 1.1.1-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.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.force-build +0 -0
  3. data/.travis.yml +8 -7
  4. data/CHANGELOG.rdoc +29 -1
  5. data/Rakefile +2 -2
  6. data/db/migrate/201311192003_reassociate_manual_approval.rb +2 -3
  7. data/db/migrate/201403181732_rename_manual_fields.rb +10 -0
  8. data/db/migrate/201403190028_add_manual_approvals.rb +22 -0
  9. data/db/migrate/201403191419_add_timestamps_to_manual_approvals.rb +15 -0
  10. data/db/migrate/201403191645_remove_license_aliases.rb +23 -0
  11. data/features/cli.feature +21 -20
  12. data/features/cocoapods_dependencies.feature +10 -0
  13. data/features/configure_bundler_groups.feature +23 -0
  14. data/features/configure_ignore_dependencies.feature +16 -0
  15. data/features/{project_name.feature → configure_project_name.feature} +1 -1
  16. data/features/{whitelist.feature → configure_whitelist.feature} +6 -6
  17. data/features/manually_added.feature +19 -0
  18. data/features/{approve_dependencies.feature → manually_approved.feature} +2 -2
  19. data/features/manually_assigned_license.feature +16 -0
  20. data/features/{text_report.feature → report_csv.feature} +2 -2
  21. data/features/{html_report.feature → report_html.feature} +2 -2
  22. data/features/step_definitions/cli_steps.rb +22 -32
  23. data/features/step_definitions/cocoapod_steps.rb +8 -0
  24. data/features/step_definitions/configure_bundler_groups_steps.rb +30 -0
  25. data/features/step_definitions/configure_ignore_dependencies.rb +35 -0
  26. data/features/step_definitions/{project_name_steps.rb → configure_project_name_steps.rb} +0 -0
  27. data/features/step_definitions/configure_whitelist_steps.rb +45 -0
  28. data/features/step_definitions/gradle_steps.rb +2 -2
  29. data/features/step_definitions/manually_added_steps.rb +28 -0
  30. data/features/step_definitions/manually_approved_steps.rb +24 -0
  31. data/features/step_definitions/manually_assigned_license_steps.rb +34 -0
  32. data/features/step_definitions/maven_steps.rb +2 -2
  33. data/features/step_definitions/node_steps.rb +2 -2
  34. data/features/step_definitions/python_steps.rb +1 -1
  35. data/features/step_definitions/report_csv_steps.rb +20 -0
  36. data/features/step_definitions/report_html_steps.rb +60 -0
  37. data/features/step_definitions/shared_steps.rb +125 -104
  38. data/{files/license_finder.yml → lib/data/license_finder.example.yml} +3 -0
  39. data/lib/license_finder.rb +3 -2
  40. data/lib/license_finder/cli.rb +94 -49
  41. data/lib/license_finder/configuration.rb +21 -14
  42. data/lib/license_finder/dependency_manager.rb +27 -19
  43. data/lib/license_finder/license.rb +33 -19
  44. data/lib/license_finder/license/definitions.rb +153 -104
  45. data/lib/license_finder/license/matcher.rb +6 -1
  46. data/lib/license_finder/license/none_matcher.rb +9 -0
  47. data/lib/license_finder/license/text.rb +1 -0
  48. data/lib/license_finder/package.rb +30 -6
  49. data/lib/license_finder/package_managers/bower.rb +2 -2
  50. data/lib/license_finder/package_managers/bower_package.rb +2 -2
  51. data/lib/license_finder/package_managers/bundler.rb +9 -17
  52. data/lib/license_finder/package_managers/bundler_package.rb +1 -1
  53. data/lib/license_finder/package_managers/cocoa_pods.rb +35 -0
  54. data/lib/license_finder/package_managers/cocoa_pods_package.rb +19 -0
  55. data/lib/license_finder/package_managers/gradle.rb +9 -5
  56. data/lib/license_finder/package_managers/gradle_package.rb +4 -4
  57. data/lib/license_finder/package_managers/maven.rb +7 -3
  58. data/lib/license_finder/package_managers/maven_package.rb +5 -5
  59. data/lib/license_finder/package_managers/npm.rb +2 -2
  60. data/lib/license_finder/package_managers/npm_package.rb +2 -2
  61. data/lib/license_finder/package_managers/pip.rb +2 -2
  62. data/lib/license_finder/package_managers/pip_package.rb +7 -11
  63. data/lib/license_finder/package_saver.rb +12 -10
  64. data/lib/license_finder/possible_license_file.rb +1 -1
  65. data/lib/license_finder/possible_license_files.rb +11 -15
  66. data/lib/license_finder/reports/formatted_report.rb +25 -6
  67. data/lib/license_finder/reports/html_report.rb +2 -1
  68. data/lib/license_finder/reports/reporter.rb +3 -3
  69. data/lib/license_finder/tables.rb +6 -4
  70. data/lib/license_finder/tables/dependency.rb +36 -16
  71. data/lib/license_finder/tables/manual_approval.rb +13 -0
  72. data/lib/license_finder/yml_to_sql.rb +12 -9
  73. data/lib/templates/html_report.erb +68 -74
  74. data/lib/templates/markdown_report.erb +20 -21
  75. data/license_finder.gemspec +7 -7
  76. data/readme.md +76 -79
  77. data/spec/fixtures/Podfile +3 -0
  78. data/spec/lib/license_finder/cli_spec.rb +71 -23
  79. data/spec/lib/license_finder/configuration_spec.rb +61 -21
  80. data/spec/lib/license_finder/dependency_manager_spec.rb +52 -33
  81. data/spec/lib/license_finder/license/definitions_spec.rb +30 -14
  82. data/spec/lib/license_finder/license_spec.rb +55 -12
  83. data/spec/lib/license_finder/package_managers/bower_package_spec.rb +38 -19
  84. data/spec/lib/license_finder/package_managers/bower_spec.rb +10 -16
  85. data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +39 -15
  86. data/spec/lib/license_finder/package_managers/bundler_spec.rb +10 -22
  87. data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +44 -0
  88. data/spec/lib/license_finder/package_managers/cocoa_pods_spec.rb +79 -0
  89. data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +4 -5
  90. data/spec/lib/license_finder/package_managers/gradle_spec.rb +26 -20
  91. data/spec/lib/license_finder/package_managers/maven_package_spec.rb +4 -5
  92. data/spec/lib/license_finder/package_managers/maven_spec.rb +16 -19
  93. data/spec/lib/license_finder/package_managers/npm_package_spec.rb +39 -19
  94. data/spec/lib/license_finder/package_managers/npm_spec.rb +10 -16
  95. data/spec/lib/license_finder/package_managers/pip_package_spec.rb +8 -8
  96. data/spec/lib/license_finder/package_managers/pip_spec.rb +10 -16
  97. data/spec/lib/license_finder/package_saver_spec.rb +27 -3
  98. data/spec/lib/license_finder/possible_license_file_spec.rb +25 -23
  99. data/spec/lib/license_finder/reports/detailed_text_report_spec.rb +6 -8
  100. data/spec/lib/license_finder/reports/html_report_spec.rb +45 -44
  101. data/spec/lib/license_finder/reports/markdown_report_spec.rb +8 -9
  102. data/spec/lib/license_finder/reports/reporter_spec.rb +1 -1
  103. data/spec/lib/license_finder/reports/text_report_spec.rb +6 -8
  104. data/spec/lib/license_finder/tables/dependency_spec.rb +57 -41
  105. data/spec/lib/license_finder/yml_to_sql_spec.rb +94 -92
  106. data/spec/spec_helper.rb +1 -0
  107. data/spec/support/stdout_helpers.rb +25 -0
  108. metadata +86 -69
  109. data/MIT.LICENSE +0 -20
  110. data/features/ignore_bundle_groups.feature +0 -23
  111. data/features/manually_managed_dependencies.feature +0 -19
  112. data/features/set_license.feature +0 -10
  113. data/features/step_definitions/approve_dependencies_steps.rb +0 -25
  114. data/features/step_definitions/html_report_steps.rb +0 -62
  115. data/features/step_definitions/ignore_bundle_groups_steps.rb +0 -29
  116. data/features/step_definitions/manually_managed_steps.rb +0 -33
  117. data/features/step_definitions/set_license_steps.rb +0 -20
  118. data/features/step_definitions/text_report_steps.rb +0 -19
  119. data/features/step_definitions/whitelist_steps.rb +0 -45
  120. data/files/dependency_breakdown.png +0 -0
  121. data/files/report_breakdown.png +0 -0
  122. data/lib/license_finder/license_url.rb +0 -9
  123. data/lib/license_finder/tables/license_alias.rb +0 -22
  124. data/spec/lib/license_finder/license_url_spec.rb +0 -16
  125. data/spec/lib/license_finder/tables/license_alias_spec.rb +0 -37
  126. data/spec/support/silence_stdout.rb +0 -13
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ module LicenseFinder
4
+ describe CocoaPods do
5
+ def stub_acknowledgments(hash = {})
6
+ plist_json = %{
7
+ {
8
+ "PreferenceSpecifiers": [
9
+ {
10
+ "FooterText": "#{hash[:license]}",
11
+ "Title": "#{hash[:name]}"
12
+ }
13
+ ]
14
+ }
15
+ }
16
+
17
+ expect(described_class).to receive(:`).with(/plutil/).and_return(plist_json)
18
+ end
19
+
20
+ def stub_lockfile(pods)
21
+ allow(YAML).to receive(:load_file).with(Pathname.new("Podfile.lock")).and_return("PODS" => pods)
22
+ end
23
+
24
+ describe '.current_packages' do
25
+ it 'lists all the current packages' do
26
+ stub_lockfile([
27
+ { "ABTest (0.0.5)" => ["OpenUDID"] },
28
+ "JSONKit (1.5pre)",
29
+ "OpenUDID (1.0.0)"
30
+ ])
31
+ stub_acknowledgments
32
+
33
+ expect(CocoaPodsPackage).to receive(:new).with("ABTest", "0.0.5", anything)
34
+ expect(CocoaPodsPackage).to receive(:new).with("JSONKit", "1.5pre", anything)
35
+ expect(CocoaPodsPackage).to receive(:new).with("OpenUDID", "1.0.0", anything)
36
+
37
+ current_packages = CocoaPods.current_packages
38
+
39
+ expect(current_packages.size).to eq(3)
40
+ end
41
+
42
+ it "passes the license text to the package" do
43
+ stub_lockfile(["Dependency Name (1.0)"])
44
+ stub_acknowledgments({name: "Dependency Name", license: "License Text"})
45
+
46
+ expect(CocoaPodsPackage).to receive(:new).with("Dependency Name", "1.0", "License Text")
47
+
48
+ CocoaPods.current_packages
49
+ end
50
+
51
+ it "handles no licenses" do
52
+ stub_lockfile(["Dependency Name (1.0)"])
53
+ stub_acknowledgments
54
+
55
+ expect(CocoaPodsPackage).to receive(:new).with("Dependency Name", "1.0", nil)
56
+
57
+ CocoaPods.current_packages
58
+ end
59
+ end
60
+
61
+ describe '.active?' do
62
+ let(:package) { double(:package_file) }
63
+
64
+ before do
65
+ CocoaPods.stub(package_path: package)
66
+ end
67
+
68
+ it 'is true with a Podfile file' do
69
+ package.stub(:exist? => true)
70
+ expect(CocoaPods).to be_active
71
+ end
72
+
73
+ it 'is false without a Podfile file' do
74
+ package.stub(:exist? => false)
75
+ expect(CocoaPods).to_not be_active
76
+ end
77
+ end
78
+ end
79
+ end
@@ -19,11 +19,10 @@ module LicenseFinder
19
19
  its(:name) { should == "logback-classic" }
20
20
  its(:version) { should == "1.1.1" }
21
21
  its(:description) { should == "" }
22
- its(:licenses_from_spec) { should == ["Eclipse Public License - v 1.0"] }
23
22
 
24
23
  describe "#license" do
25
24
  it "returns the license if found" do
26
- subject.license.should == "Eclipse Public License - v 1.0"
25
+ subject.license.name.should == "Eclipse Public License - v 1.0"
27
26
  end
28
27
 
29
28
  context "when there are multiple licenses" do
@@ -40,8 +39,8 @@ module LicenseFinder
40
39
  )
41
40
  end
42
41
 
43
- it "returns 'other'" do
44
- subject.license.should == 'other'
42
+ it "returns 'multiple licenses'" do
43
+ subject.license.name.should == 'multiple licenses: Eclipse Public License - v 1.0, GNU Lesser General Public License'
45
44
  end
46
45
  end
47
46
 
@@ -57,7 +56,7 @@ module LicenseFinder
57
56
  end
58
57
 
59
58
  it "returns 'other' otherwise" do
60
- subject.license.should == "other"
59
+ subject.license.name.should == "other"
61
60
  end
62
61
  end
63
62
  end
@@ -12,7 +12,8 @@ module LicenseFinder
12
12
 
13
13
  describe '.current_packages' do
14
14
  before do
15
- expect(described_class).to receive(:`).with(/gradle downloadLicenses/)
15
+ allow(LicenseFinder.config).to receive(:gradle_command) { 'gradlefoo' }
16
+ expect(described_class).to receive(:`).with(/gradlefoo downloadLicenses/)
16
17
  end
17
18
 
18
19
  it 'lists all the current packages' do
@@ -26,7 +27,8 @@ module LicenseFinder
26
27
  <license name='The Apache Software License, Version 2.0' url='http://www.apache.org/licenses/LICENSE-2.0.txt' />
27
28
  </dependency>
28
29
  """)
29
- allow(File).to receive(:read).with("build/reports/license/dependency-license.xml").and_return(license_xml)
30
+ fake_file = double(:license_report, read: license_xml)
31
+ allow(Gradle).to receive(:license_report).and_return(fake_file)
30
32
 
31
33
  current_packages = described_class.current_packages
32
34
 
@@ -42,7 +44,8 @@ module LicenseFinder
42
44
  </dependency>
43
45
  """)
44
46
 
45
- allow(File).to receive(:read).with("build/reports/license/dependency-license.xml").and_return(license_xml)
47
+ fake_file = double(:license_report, read: license_xml)
48
+ allow(Gradle).to receive(:license_report).and_return(fake_file)
46
49
 
47
50
  GradlePackage.should_receive(:new).with("license" => [{"name" => "License 1"}, {"name" => "License 2"}])
48
51
  Gradle.current_packages
@@ -55,34 +58,37 @@ module LicenseFinder
55
58
  </dependency>
56
59
  """)
57
60
 
58
- allow(File).to receive(:read).with("build/reports/license/dependency-license.xml").and_return(license_xml)
61
+ fake_file = double(:license_report, read: license_xml)
62
+ allow(Gradle).to receive(:license_report).and_return(fake_file)
59
63
 
60
64
  GradlePackage.should_receive(:new).with("license" => [])
61
65
  Gradle.current_packages
62
66
  end
67
+
68
+ it "handles an empty list of licenses" do
69
+ license_xml = license_xml("")
70
+
71
+ fake_file = double(:license_report, read: license_xml)
72
+ allow(Gradle).to receive(:license_report).and_return(fake_file)
73
+ Gradle.current_packages
74
+ end
63
75
  end
64
76
 
65
77
  describe '.active?' do
66
- let(:package) { Pathname.new('build.gradle').expand_path }
78
+ let(:package) { double(:package_file) }
67
79
 
68
- context 'with a build.gradle file' do
69
- before :each do
70
- allow(File).to receive(:exists?).with(package).and_return(true)
71
- end
72
-
73
- it 'returns true' do
74
- expect(Gradle.active?).to eq(true)
75
- end
80
+ before do
81
+ Gradle.stub(package_path: package)
76
82
  end
77
83
 
78
- context 'without a build.gradle file' do
79
- before :each do
80
- allow(File).to receive(:exists?).with(package).and_return(false)
81
- end
84
+ it 'is true with a build.gradle file' do
85
+ package.stub(:exist? => true)
86
+ expect(Gradle).to be_active
87
+ end
82
88
 
83
- it 'returns false' do
84
- expect(Gradle.active?).to eq(false)
85
- end
89
+ it 'is false without a build.gradle file' do
90
+ package.stub(:exist? => false)
91
+ expect(Gradle).to_not be_active
86
92
  end
87
93
  end
88
94
  end
@@ -21,11 +21,10 @@ module LicenseFinder
21
21
  its(:name) { should == "hamcrest-core" }
22
22
  its(:version) { should == "4.11" }
23
23
  its(:description) { should == "" }
24
- its(:licenses_from_spec) { should == ["Common Public License Version 1.0"] }
25
24
 
26
25
  describe "#license" do
27
26
  it "returns the license if found" do
28
- subject.license.should == "Common Public License Version 1.0"
27
+ subject.license.name.should == "Common Public License Version 1.0"
29
28
  end
30
29
 
31
30
  context "when there are multiple licenses" do
@@ -46,8 +45,8 @@ module LicenseFinder
46
45
  )
47
46
  end
48
47
 
49
- it "returns 'other'" do
50
- subject.license.should == 'other'
48
+ it "returns 'multiple licenses'" do
49
+ subject.license.name.should == 'multiple licenses: Common Public License Version 1.0, Apache 2'
51
50
  end
52
51
  end
53
52
 
@@ -63,7 +62,7 @@ module LicenseFinder
63
62
  end
64
63
 
65
64
  it "returns 'other' otherwise" do
66
- subject.license.should == "other"
65
+ subject.license.name.should == "other"
67
66
  end
68
67
  end
69
68
  end
@@ -44,7 +44,8 @@ module LicenseFinder
44
44
  </licenses>
45
45
  </dependency>
46
46
  """)
47
- allow(File).to receive(:read).with("target/generated-resources/licenses.xml").and_return(license_xml)
47
+ fake_file = double(:license_report, read: license_xml)
48
+ allow(Maven).to receive(:license_report).and_return(fake_file)
48
49
 
49
50
  current_packages = Maven.current_packages
50
51
 
@@ -66,7 +67,8 @@ module LicenseFinder
66
67
  </dependency>
67
68
  """)
68
69
 
69
- allow(File).to receive(:read).with("target/generated-resources/licenses.xml").and_return(license_xml)
70
+ fake_file = double(:license_report, read: license_xml)
71
+ allow(Maven).to receive(:license_report).and_return(fake_file)
70
72
 
71
73
  MavenPackage.should_receive(:new).with("licenses" => [{"name" => "License 1"}, {"name" => "License 2"}])
72
74
  Maven.current_packages
@@ -81,7 +83,8 @@ module LicenseFinder
81
83
  </dependency>
82
84
  """)
83
85
 
84
- allow(File).to receive(:read).with("target/generated-resources/licenses.xml").and_return(license_xml)
86
+ fake_file = double(:license_report, read: license_xml)
87
+ allow(Maven).to receive(:license_report).and_return(fake_file)
85
88
 
86
89
  MavenPackage.should_receive(:new).with("licenses" => {})
87
90
  Maven.current_packages
@@ -89,26 +92,20 @@ module LicenseFinder
89
92
  end
90
93
 
91
94
  describe '.active?' do
92
- let(:package) { Pathname.new('pom.xml').expand_path }
95
+ let(:package) { double(:package_file) }
93
96
 
94
- context 'with a pom.xml file' do
95
- before :each do
96
- allow(File).to receive(:exists?).with(package).and_return(true)
97
- end
98
-
99
- it 'returns true' do
100
- expect(Maven.active?).to eq(true)
101
- end
97
+ before do
98
+ allow(Maven).to receive(:package_path).and_return(package)
102
99
  end
103
100
 
104
- context 'without a pom.xml file' do
105
- before :each do
106
- allow(File).to receive(:exists?).with(package).and_return(false)
107
- end
101
+ it 'is true with a pom.xml file' do
102
+ allow(package).to receive(:exist?).and_return(true)
103
+ expect(Maven.active?).to eq(true)
104
+ end
108
105
 
109
- it 'returns false' do
110
- expect(Maven.active?).to eq(false)
111
- end
106
+ it 'is false without a pom.xml file' do
107
+ allow(package).to receive(:exist?).and_return(false)
108
+ expect(Maven.active?).to eq(false)
112
109
  end
113
110
  end
114
111
  end
@@ -32,36 +32,56 @@ module LicenseFinder
32
32
  let(:node_module2) { {"licenses" => [{"type" => "BSD"}], "path" => "/some/path"} }
33
33
  let(:node_module3) { {"license" => {"type" => "PSF"}, "path" => "/some/path"} }
34
34
  let(:node_module4) { {"licenses" => ["MIT"], "path" => "/some/path"} }
35
+ let(:misdeclared_node_module) { {"licenses" => {"type" => "MIT"}} }
35
36
 
36
37
  it 'finds the license for both license structures' do
37
- NpmPackage.new(node_module1).license.should eq("MIT")
38
- NpmPackage.new(node_module2).license.should eq("BSD")
39
- NpmPackage.new(node_module3).license.should eq("PSF")
40
- NpmPackage.new(node_module4).license.should eq("MIT")
38
+ NpmPackage.new(node_module1).license.name.should eq("MIT")
39
+ NpmPackage.new(node_module2).license.name.should eq("BSD")
40
+ NpmPackage.new(node_module3).license.name.should eq("Python Software Foundation License")
41
+ NpmPackage.new(node_module4).license.name.should eq("MIT")
42
+ NpmPackage.new(misdeclared_node_module).license.name.should eq("MIT")
41
43
  end
42
44
 
43
- it "returns a license in a file if detected" do
44
- stub_license_files [double(:file, license: 'Detected License')]
45
+ context "regardless of whether there are licenses in files" do
46
+ before do
47
+ stub_license_files [double(:file, license: License.find_by_name('Detected License'))]
48
+ end
45
49
 
46
- subject.license.should == "Detected License"
47
- end
50
+ it "returns the license from the spec if there is only one unique license" do
51
+ package = NpmPackage.new({ "licenses" => ["MIT", "Expat"], "path" => "/path/to/thing" })
52
+ expect(package.license.name).to eq("MIT")
53
+ end
48
54
 
49
- it "returns other if there's more than one license" do
50
- package = NpmPackage.new({ "licenses" => ["MIT", "BSD"], "path" => "/some/path" })
51
- expect(package.license).to eq("other")
55
+ it "returns 'multiple licenses' if there's more than one license" do
56
+ package = NpmPackage.new({ "licenses" => ["MIT", "BSD"], "path" => "/some/path" })
57
+ expect(package.license.name).to eq("multiple licenses: MIT, BSD")
58
+ end
52
59
  end
53
60
 
54
- it "returns other if the license from spec and license from files are different" do
55
- stub_license_files [double(:file, license: 'Detected License')]
56
- package = NpmPackage.new({ "licenses" => ["MIT"], "path" => "some/node/package/path" })
61
+ context "when there is nothing in the spec" do
62
+ it "returns a license in a file if only one unique license detected" do
63
+ stub_license_files([
64
+ double(:first_file, license: License.find_by_name('MIT')),
65
+ double(:second_file, license: License.find_by_name('Expat'))
66
+ ])
57
67
 
58
- expect(package.license).to eq("other")
59
- end
68
+ subject.license.name.should == "MIT"
69
+ end
70
+
71
+ it "returns 'other' if there are no licenses in files" do
72
+ stub_license_files []
73
+
74
+ subject.license.name.should == "other"
75
+ end
60
76
 
61
- it "returns 'other' otherwise" do
62
- stub_license_files []
77
+ it "returns 'other' if there are many licenses in files" do
78
+ stub_license_files([
79
+ double(:first_file, license: License.find_by_name('First Detected License')),
80
+ double(:second_file, license: License.find_by_name('Second Detected License'))
81
+ ])
63
82
 
64
- subject.license.should == "other"
83
+ subject.license.name.should == "multiple licenses: First Detected License, Second Detected License"
84
+ end
65
85
  end
66
86
  end
67
87
  end
@@ -98,26 +98,20 @@ module LicenseFinder
98
98
  end
99
99
 
100
100
  describe '.active?' do
101
- let(:package) { Pathname.new('package.json').expand_path }
101
+ let(:package) { double(:package_file) }
102
102
 
103
- context 'with a package.json file' do
104
- before :each do
105
- allow(File).to receive(:exists?).with(package).and_return(true)
106
- end
107
-
108
- it 'returns true' do
109
- expect(NPM.active?).to eq(true)
110
- end
103
+ before do
104
+ NPM.stub(package_path: package)
111
105
  end
112
106
 
113
- context 'without a package file' do
114
- before :each do
115
- allow(File).to receive(:exists?).with(package).and_return(false)
116
- end
107
+ it 'is true with a package.json file' do
108
+ package.stub(:exist? => true)
109
+ expect(NPM).to be_active
110
+ end
117
111
 
118
- it 'returns false' do
119
- expect(NPM.active?).to eq(false)
120
- end
112
+ it 'is false without a package.json file' do
113
+ package.stub(:exist? => false)
114
+ expect(NPM).to_not be_active
121
115
  end
122
116
  end
123
117
  end
@@ -56,7 +56,7 @@ module LicenseFinder
56
56
 
57
57
  subject = make_package(data)
58
58
 
59
- expect(subject.license).to eq('MIT')
59
+ expect(subject.license.name).to eq('MIT')
60
60
  end
61
61
 
62
62
  context "when there's no explicit license" do
@@ -65,15 +65,15 @@ module LicenseFinder
65
65
 
66
66
  subject = make_package(data)
67
67
 
68
- expect(subject.license).to eq('Apache 2.0 License')
68
+ expect(subject.license.name).to eq('Apache 2.0 License')
69
69
  end
70
70
 
71
- it "returns 'other' if there is are multiple licenses in 'classifiers'" do
71
+ it "returns 'multiple licenses' if there are multiple licenses in 'classifiers'" do
72
72
  data = { "classifiers" => [ 'License :: OSI Approved :: Apache 2.0 License', 'License :: OSI Approved :: GPL' ] }
73
73
 
74
74
  subject = make_package(data)
75
75
 
76
- expect(subject.license).to eq('other')
76
+ expect(subject.license.name).to eq('multiple licenses: Apache 2.0 License, GPL')
77
77
  end
78
78
  end
79
79
 
@@ -84,7 +84,7 @@ module LicenseFinder
84
84
 
85
85
  subject = make_package(data)
86
86
 
87
- expect(subject.license).to eq('Apache 2.0 License')
87
+ expect(subject.license.name).to eq('Apache 2.0 License')
88
88
  end
89
89
  end
90
90
  end
@@ -96,13 +96,13 @@ module LicenseFinder
96
96
  end
97
97
 
98
98
  it 'returns license from file' do
99
- stub_license_files [double(:license_file, license: 'License from file')]
100
- expect(subject.license).to eq('License from file')
99
+ stub_license_files [double(:license_file, license: License.find_by_name('License from file'))]
100
+ expect(subject.license.name).to eq('License from file')
101
101
  end
102
102
 
103
103
  it 'returns other if no license can be found' do
104
104
  stub_license_files []
105
- expect(subject.license).to eq('other')
105
+ expect(subject.license.name).to eq('other')
106
106
  end
107
107
  end
108
108
  end