license_finder 3.0.4 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +56 -0
  3. data/CHANGELOG.md +29 -2
  4. data/CONTRIBUTING.md +5 -1
  5. data/Dockerfile +33 -10
  6. data/Gemfile +2 -2
  7. data/README.md +27 -5
  8. data/Rakefile +15 -21
  9. data/ci/pipelines/pipeline.yml.erb +40 -6
  10. data/ci/pipelines/release.yml +11 -5
  11. data/ci/scripts/containerize-tests.sh +16 -0
  12. data/ci/scripts/run-rubocop.sh +8 -0
  13. data/ci/scripts/run-tests.sh +22 -0
  14. data/ci/scripts/test.ps1 +81 -0
  15. data/ci/tasks/build-windows.yml +6 -0
  16. data/ci/tasks/build.yml +2 -2
  17. data/ci/tasks/rubocop.yml +13 -0
  18. data/features/features/cli/cli_spec.rb +8 -8
  19. data/features/features/configure/add_dependencies_spec.rb +7 -7
  20. data/features/features/configure/approve_dependencies_spec.rb +15 -15
  21. data/features/features/configure/assign_licenses_spec.rb +4 -4
  22. data/features/features/configure/blacklist_licenses_spec.rb +3 -3
  23. data/features/features/configure/ignore_dependencies_spec.rb +3 -3
  24. data/features/features/configure/ignore_groups_spec.rb +4 -4
  25. data/features/features/configure/name_project_spec.rb +4 -4
  26. data/features/features/configure/set_project_path_spec.rb +2 -2
  27. data/features/features/configure/whitelist_licenses_spec.rb +4 -4
  28. data/features/features/package_managers/bower_spec.rb +3 -3
  29. data/features/features/package_managers/carthage_spec.rb +14 -0
  30. data/features/features/package_managers/cocoapods_spec.rb +3 -3
  31. data/features/features/package_managers/conan_spec.rb +11 -0
  32. data/features/features/package_managers/dep_spec.rb +15 -0
  33. data/features/features/package_managers/glide_spec.rb +14 -0
  34. data/features/features/package_managers/govendor_spec.rb +15 -0
  35. data/features/features/package_managers/gradle_spec.rb +1 -1
  36. data/features/features/package_managers/gvt_spec.rb +14 -0
  37. data/features/features/package_managers/maven_spec.rb +2 -3
  38. data/features/features/package_managers/mix_spec.rb +16 -0
  39. data/features/features/package_managers/npm_spec.rb +3 -3
  40. data/features/features/package_managers/nuget_spec.rb +4 -4
  41. data/features/features/package_managers/pip_spec.rb +2 -2
  42. data/features/features/package_managers/rebar_spec.rb +3 -3
  43. data/features/features/package_managers/yarn_spec.rb +14 -0
  44. data/features/features/report/composite_spec.rb +1 -1
  45. data/features/features/report/csv_spec.rb +3 -3
  46. data/features/features/report/diff_spec.rb +20 -10
  47. data/features/features/report/html_spec.rb +10 -10
  48. data/features/features/report/subproject_spec.rb +15 -4
  49. data/features/fixtures/Cartfile +1 -0
  50. data/features/fixtures/Podfile +1 -1
  51. data/features/fixtures/alternate-build-file-gradle/build-alt.gradle +5 -15
  52. data/features/fixtures/build.gradle +5 -15
  53. data/features/fixtures/conanfile.txt +11 -0
  54. data/features/fixtures/file-based-libs-gradle/build.gradle +5 -7
  55. data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.lock +9 -0
  56. data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.toml +7 -0
  57. data/features/fixtures/gopath_dep/src/foo-dep/bar/bar.go +10 -0
  58. data/features/fixtures/gopath_dep/src/foo-dep/foo.go +7 -0
  59. data/features/fixtures/gopath_glide/src/glide.lock +9 -0
  60. data/features/fixtures/gopath_glide/src/glide.yaml +6 -0
  61. data/features/fixtures/gopath_govendor/src/vendor/vendor.json +19 -0
  62. data/features/fixtures/gopath_gvt/src/vendor/manifest +22 -0
  63. data/features/fixtures/gradle-wrapper/build.gradle +5 -15
  64. data/features/fixtures/gradle-wrapper/gradlew +6 -1
  65. data/features/fixtures/gradle-wrapper/gradlew.bat +9 -1
  66. data/features/fixtures/mix.exs +22 -0
  67. data/features/fixtures/multi-module-gradle/build.gradle +7 -15
  68. data/features/fixtures/single-module-gradle/build.gradle +5 -15
  69. data/features/support/testing_dsl.rb +155 -43
  70. data/lib/license_finder.rb +4 -3
  71. data/lib/license_finder/cli.rb +0 -3
  72. data/lib/license_finder/cli/approvals.rb +3 -3
  73. data/lib/license_finder/cli/base.rb +11 -8
  74. data/lib/license_finder/cli/blacklist.rb +7 -7
  75. data/lib/license_finder/cli/dependencies.rb +8 -8
  76. data/lib/license_finder/cli/ignored_dependencies.rb +4 -4
  77. data/lib/license_finder/cli/ignored_groups.rb +4 -4
  78. data/lib/license_finder/cli/licenses.rb +2 -2
  79. data/lib/license_finder/cli/main.rb +59 -39
  80. data/lib/license_finder/cli/makes_decisions.rb +2 -2
  81. data/lib/license_finder/cli/patched_thor.rb +6 -7
  82. data/lib/license_finder/cli/project_name.rb +5 -6
  83. data/lib/license_finder/cli/whitelist.rb +7 -7
  84. data/lib/license_finder/configuration.rb +15 -4
  85. data/lib/license_finder/core.rb +20 -4
  86. data/lib/license_finder/decision_applier.rb +0 -1
  87. data/lib/license_finder/decisions.rb +12 -14
  88. data/lib/license_finder/diff.rb +33 -31
  89. data/lib/license_finder/license.rb +13 -9
  90. data/lib/license_finder/license/definitions.rb +55 -55
  91. data/lib/license_finder/license/none_matcher.rb +1 -1
  92. data/lib/license_finder/license/template.rb +1 -1
  93. data/lib/license_finder/license/text.rb +0 -1
  94. data/lib/license_finder/license_aggregator.rb +1 -0
  95. data/lib/license_finder/logger.rb +18 -61
  96. data/lib/license_finder/package.rb +25 -11
  97. data/lib/license_finder/package_delta.rb +3 -6
  98. data/lib/license_finder/package_manager.rb +77 -34
  99. data/lib/license_finder/package_managers/bower.rb +8 -8
  100. data/lib/license_finder/package_managers/bower_package.rb +12 -12
  101. data/lib/license_finder/package_managers/bundler.rb +21 -9
  102. data/lib/license_finder/package_managers/bundler_package.rb +1 -1
  103. data/lib/license_finder/package_managers/carthage.rb +66 -0
  104. data/lib/license_finder/package_managers/carthage_package.rb +16 -0
  105. data/lib/license_finder/package_managers/cocoa_pods.rb +13 -13
  106. data/lib/license_finder/package_managers/cocoa_pods_package.rb +1 -1
  107. data/lib/license_finder/package_managers/conan.rb +26 -0
  108. data/lib/license_finder/package_managers/conan_info_parser.rb +74 -0
  109. data/lib/license_finder/package_managers/conan_package.rb +17 -0
  110. data/lib/license_finder/package_managers/dep.rb +33 -0
  111. data/lib/license_finder/package_managers/glide.rb +30 -0
  112. data/lib/license_finder/package_managers/{go_vendor.rb → go_15vendorexperiment.rb} +19 -24
  113. data/lib/license_finder/package_managers/go_dep.rb +15 -12
  114. data/lib/license_finder/package_managers/go_package.rb +15 -13
  115. data/lib/license_finder/package_managers/go_workspace.rb +39 -34
  116. data/lib/license_finder/package_managers/govendor.rb +32 -0
  117. data/lib/license_finder/package_managers/gradle.rb +16 -16
  118. data/lib/license_finder/package_managers/gradle_package.rb +8 -8
  119. data/lib/license_finder/package_managers/gvt.rb +61 -0
  120. data/lib/license_finder/package_managers/maven.rb +17 -18
  121. data/lib/license_finder/package_managers/maven_package.rb +4 -6
  122. data/lib/license_finder/package_managers/merged_package.rb +25 -2
  123. data/lib/license_finder/package_managers/mix.rb +51 -0
  124. data/lib/license_finder/package_managers/mix_package.rb +7 -0
  125. data/lib/license_finder/package_managers/npm.rb +8 -32
  126. data/lib/license_finder/package_managers/npm_package.rb +51 -48
  127. data/lib/license_finder/package_managers/nuget.rb +30 -40
  128. data/lib/license_finder/package_managers/pip.rb +11 -11
  129. data/lib/license_finder/package_managers/pip_package.rb +8 -8
  130. data/lib/license_finder/package_managers/rebar.rb +11 -11
  131. data/lib/license_finder/package_managers/yarn.rb +62 -0
  132. data/lib/license_finder/packages/activation.rb +2 -2
  133. data/lib/license_finder/packages/license_files.rb +6 -6
  134. data/lib/license_finder/packages/licensing.rb +8 -10
  135. data/lib/license_finder/packages/manual_package.rb +2 -2
  136. data/lib/license_finder/project_finder.rb +6 -5
  137. data/lib/license_finder/report.rb +1 -0
  138. data/lib/license_finder/reports/csv_report.rb +4 -4
  139. data/lib/license_finder/reports/diff_report.rb +2 -2
  140. data/lib/license_finder/reports/erb_report.rb +2 -4
  141. data/lib/license_finder/reports/html_report.rb +2 -2
  142. data/lib/license_finder/reports/markdown_report.rb +1 -1
  143. data/lib/license_finder/reports/merged_report.rb +1 -1
  144. data/lib/license_finder/reports/text_report.rb +3 -5
  145. data/lib/license_finder/shared_helpers/cmd.rb +11 -0
  146. data/lib/license_finder/version.rb +1 -1
  147. data/license_finder-2.1.2.gem +0 -0
  148. data/license_finder.gemspec +38 -38
  149. metadata +84 -118
  150. data/ci/scripts/test.sh +0 -26
  151. data/ci/tasks/create-source-archives.yml +0 -23
  152. data/spec/dummy_app/Gemfile +0 -6
  153. data/spec/fixtures/all_pms/.envrc +0 -1
  154. data/spec/fixtures/all_pms/.nuget/.keep +0 -0
  155. data/spec/fixtures/all_pms/Gemfile +0 -0
  156. data/spec/fixtures/all_pms/Godeps/Godeps.json +0 -0
  157. data/spec/fixtures/all_pms/Podfile +0 -0
  158. data/spec/fixtures/all_pms/bower.json +0 -0
  159. data/spec/fixtures/all_pms/build.gradle +0 -0
  160. data/spec/fixtures/all_pms/package.json +0 -0
  161. data/spec/fixtures/all_pms/pom.xml +0 -0
  162. data/spec/fixtures/all_pms/rebar.config +0 -0
  163. data/spec/fixtures/all_pms/requirements.txt +0 -0
  164. data/spec/fixtures/all_pms/vendor/.gitkeep +0 -0
  165. data/spec/fixtures/composite/Gemfile +0 -0
  166. data/spec/fixtures/composite/nested_project/.envrc +0 -8
  167. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Godeps.json +0 -16
  168. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Readme +0 -5
  169. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/foo.go +0 -6
  170. data/spec/fixtures/composite/not_a_project/DONTREADME.md +0 -0
  171. data/spec/fixtures/composite/project1/Gemfile +0 -0
  172. data/spec/fixtures/composite/project2/package.json +0 -0
  173. data/spec/fixtures/config/license_finder.yml +0 -5
  174. data/spec/fixtures/license_directory/COPYING +0 -1
  175. data/spec/fixtures/license_directory/LICENSE/MIT.txt +0 -1
  176. data/spec/fixtures/license_directory/LICENSE/lib/unrelated.txt +0 -2
  177. data/spec/fixtures/license_names/COPYING.txt +0 -1
  178. data/spec/fixtures/license_names/LICENSE +0 -1
  179. data/spec/fixtures/license_names/Licence.rdoc +0 -1
  180. data/spec/fixtures/license_names/Mit-License +0 -1
  181. data/spec/fixtures/license_names/README.rdoc +0 -1
  182. data/spec/fixtures/nested_gem/vendor/LICENSE +0 -1
  183. data/spec/fixtures/npm-circular-dependencies/npm-list.json +0 -5339
  184. data/spec/fixtures/npm-circular-dependencies/package.json +0 -5
  185. data/spec/fixtures/npm-circular-licenses/npm-list.json +0 -7597
  186. data/spec/fixtures/npm-circular-licenses/package.json +0 -23
  187. data/spec/fixtures/npm-licenses-string/npm-list.json +0 -7597
  188. data/spec/fixtures/npm-licenses-string/package.json +0 -23
  189. data/spec/fixtures/npm-recursive-dependencies/npm-list.json +0 -5158
  190. data/spec/fixtures/npm-recursive-dependencies/package.json +0 -15
  191. data/spec/fixtures/npm-stack-too-deep/npm-list.json +0 -13464
  192. data/spec/fixtures/npm-stack-too-deep/package.json +0 -5
  193. data/spec/fixtures/utf8_gem/README +0 -210
  194. data/spec/lib/license_finder/cli/approvals_spec.rb +0 -71
  195. data/spec/lib/license_finder/cli/blacklist_spec.rb +0 -58
  196. data/spec/lib/license_finder/cli/dependencies_spec.rb +0 -73
  197. data/spec/lib/license_finder/cli/ignored_dependencies_spec.rb +0 -47
  198. data/spec/lib/license_finder/cli/ignored_groups_spec.rb +0 -40
  199. data/spec/lib/license_finder/cli/licenses_spec.rb +0 -60
  200. data/spec/lib/license_finder/cli/main_spec.rb +0 -243
  201. data/spec/lib/license_finder/cli/project_name_spec.rb +0 -40
  202. data/spec/lib/license_finder/cli/whitelist_spec.rb +0 -58
  203. data/spec/lib/license_finder/configuration_spec.rb +0 -115
  204. data/spec/lib/license_finder/core_spec.rb +0 -54
  205. data/spec/lib/license_finder/decision_applier_spec.rb +0 -219
  206. data/spec/lib/license_finder/decisions_spec.rb +0 -408
  207. data/spec/lib/license_finder/diff_spec.rb +0 -129
  208. data/spec/lib/license_finder/license/definitions_spec.rb +0 -177
  209. data/spec/lib/license_finder/license_aggregator_spec.rb +0 -61
  210. data/spec/lib/license_finder/license_spec.rb +0 -106
  211. data/spec/lib/license_finder/package_delta_spec.rb +0 -18
  212. data/spec/lib/license_finder/package_manager_spec.rb +0 -62
  213. data/spec/lib/license_finder/package_managers/bower_package_spec.rb +0 -71
  214. data/spec/lib/license_finder/package_managers/bower_spec.rb +0 -39
  215. data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +0 -35
  216. data/spec/lib/license_finder/package_managers/bundler_spec.rb +0 -56
  217. data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +0 -48
  218. data/spec/lib/license_finder/package_managers/cocoa_pods_spec.rb +0 -59
  219. data/spec/lib/license_finder/package_managers/go_dep_spec.rb +0 -126
  220. data/spec/lib/license_finder/package_managers/go_package_spec.rb +0 -33
  221. data/spec/lib/license_finder/package_managers/go_vendor_spec.rb +0 -144
  222. data/spec/lib/license_finder/package_managers/go_workspace_spec.rb +0 -286
  223. data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +0 -80
  224. data/spec/lib/license_finder/package_managers/gradle_spec.rb +0 -180
  225. data/spec/lib/license_finder/package_managers/maven_package_spec.rb +0 -63
  226. data/spec/lib/license_finder/package_managers/maven_spec.rb +0 -128
  227. data/spec/lib/license_finder/package_managers/merged_package_spec.rb +0 -60
  228. data/spec/lib/license_finder/package_managers/npm_package_spec.rb +0 -57
  229. data/spec/lib/license_finder/package_managers/npm_spec.rb +0 -253
  230. data/spec/lib/license_finder/package_managers/nuget_package_spec.rb +0 -9
  231. data/spec/lib/license_finder/package_managers/nuget_spec.rb +0 -157
  232. data/spec/lib/license_finder/package_managers/pip_package_spec.rb +0 -87
  233. data/spec/lib/license_finder/package_managers/pip_spec.rb +0 -47
  234. data/spec/lib/license_finder/package_managers/rebar_package_spec.rb +0 -24
  235. data/spec/lib/license_finder/package_managers/rebar_spec.rb +0 -50
  236. data/spec/lib/license_finder/package_spec.rb +0 -179
  237. data/spec/lib/license_finder/packages/activation_spec.rb +0 -41
  238. data/spec/lib/license_finder/packages/license_files_spec.rb +0 -46
  239. data/spec/lib/license_finder/packages/licensing_spec.rb +0 -1
  240. data/spec/lib/license_finder/packages/possible_license_file_spec.rb +0 -38
  241. data/spec/lib/license_finder/project_finder_spec.rb +0 -33
  242. data/spec/lib/license_finder/reports/csv_report_spec.rb +0 -70
  243. data/spec/lib/license_finder/reports/diff_report_spec.rb +0 -56
  244. data/spec/lib/license_finder/reports/html_report_spec.rb +0 -101
  245. data/spec/lib/license_finder/reports/markdown_report_spec.rb +0 -45
  246. data/spec/lib/license_finder/reports/merged_report_spec.rb +0 -21
  247. data/spec/lib/license_finder/reports/text_report_spec.rb +0 -43
  248. data/spec/spec_helper.rb +0 -27
  249. data/spec/support/shared_examples_for_package_manager.rb +0 -52
  250. data/spec/support/stdout_helpers.rb +0 -31
  251. data/spec/support/test_fixtures.rb +0 -7
@@ -1 +0,0 @@
1
- # tested via Package#licenses
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module LicenseFinder
4
- describe PossibleLicenseFile do
5
- context "file parsing" do
6
- subject { described_class.new('root/nested/path') }
7
-
8
- context "ignoring text" do
9
- before do
10
- allow(subject).to receive(:text).and_return('file text')
11
- end
12
-
13
- its(:text) { should == 'file text' } # this is a terrible test, considering the stubbing
14
- its(:path) { should == 'root/nested/path' }
15
- end
16
- end
17
-
18
- subject { described_class.new('gem/license/path') }
19
-
20
- context "with a known license" do
21
- before do
22
- allow(subject).to receive(:text).and_return('a known license')
23
-
24
- allow(License).to receive(:find_by_text).with('a known license').and_return(License.find_by_name("MIT"))
25
- end
26
-
27
- its(:license) { should == License.find_by_name("MIT") }
28
- end
29
-
30
- context "with an unknown license" do
31
- before do
32
- allow(subject).to receive(:text).and_return('')
33
- end
34
-
35
- its(:license) { should be_nil }
36
- end
37
- end
38
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module LicenseFinder
4
- describe ProjectFinder do
5
- describe '#find_projects' do
6
- it 'returns absolute paths for projects with active package managers' do
7
- finder = ProjectFinder.new('spec/fixtures/composite')
8
-
9
- active_projects = finder.find_projects
10
- expect(has_project_path?(active_projects, 'composite')).to be true
11
- expect(has_project_path?(active_projects, 'composite/project1')).to be true
12
- expect(has_project_path?(active_projects, 'composite/project2')).to be true
13
- expect(has_project_path?(active_projects, 'composite/not_a_project')).to be false
14
- end
15
-
16
- it 'searches for projects in project_path' do
17
- expect(Dir).to receive(:glob).with('/path/to/projects/**/').and_return([])
18
- ProjectFinder.new('/path/to/projects').find_projects
19
- end
20
-
21
- it 'rejects nested dependencies' do
22
- finder = ProjectFinder.new('spec/fixtures/composite')
23
-
24
- active_projects = finder.find_projects
25
- expect(has_project_path?(active_projects, 'pivotal/foo')).to be false
26
- end
27
- end
28
-
29
- def has_project_path?(projects, path)
30
- projects.any? { |p| p.end_with?(path) }
31
- end
32
- end
33
- end
@@ -1,70 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module LicenseFinder
4
- describe CsvReport do
5
- it "accepts a custom list of columns" do
6
- dep = Package.new('gem_a', '1.0')
7
- subject = described_class.new([dep], columns: %w[name version])
8
- expect(subject.to_s).to eq("gem_a,1.0\n")
9
- end
10
-
11
- it "understands many columns" do
12
- dep = Package.new('gem_a', '1.0', authors: "the authors", description: "A description", summary: "A summary", homepage: "http://homepage.example.com")
13
- dep.decide_on_license(License.find_by_name("MIT"))
14
- dep.decide_on_license(License.find_by_name("GPL"))
15
- dep.whitelisted!
16
- subject = described_class.new([dep], columns: %w[name version authors licenses approved summary description homepage])
17
- expect(subject.to_s).to eq("gem_a,1.0,the authors,\"MIT,GPL\",Approved,A summary,A description,http://homepage.example.com\n")
18
- end
19
-
20
- it "ignores unknown columns" do
21
- dep = Package.new('gem_a', '1.0')
22
- subject = described_class.new([dep], columns: %w[unknown])
23
- expect(subject.to_s).to eq("\n")
24
- end
25
-
26
- it 'supports install_path column' do
27
- dep = Package.new('gem_a', '1.0', install_path: '/tmp/gems/gem_a-1.0')
28
- subject = described_class.new([dep], columns: %w[name version install_path])
29
- expect(subject.to_s).to eq("gem_a,1.0,/tmp/gems/gem_a-1.0\n")
30
- end
31
-
32
- it 'supports package_manager column' do
33
- dep = NugetPackage.new('gem_a', '1.0')
34
- subject = described_class.new([dep], columns: %w[name version package_manager])
35
- expect(subject.to_s).to eq("gem_a,1.0,Nuget\n")
36
- end
37
-
38
- it 'supports license_links column' do
39
- dep = Package.new('gem_a', '1.0')
40
- mit = License.find_by_name("MIT")
41
- dep.decide_on_license(mit)
42
- subject = described_class.new([dep], columns: %w[name licenses license_links])
43
- expect(subject.to_s).to eq("gem_a,MIT,#{mit.url}\n")
44
- end
45
-
46
- it "does not include columns that should only be in merged reports" do
47
- dep = Package.new('gem_a', '1.0')
48
- subject = described_class.new([dep], columns: %w[subproject_paths])
49
- expect(subject.to_s).to eq("\n")
50
- end
51
-
52
- context "when no groups are specified" do
53
- let( :dep ) { Package.new('gem_a', '1.0') }
54
- subject { described_class.new([dep], columns: %w[name version groups]) }
55
-
56
- it 'supports a groups column' do
57
- expect(subject.to_s).to eq("gem_a,1.0,\"\"\n")
58
- end
59
- end
60
-
61
- context "when some groups are specified" do
62
- let( :dep ) { Package.new('gem_a', '1.0', groups: %w[development production]) }
63
- subject { described_class.new([dep], columns: %w[name version groups]) }
64
-
65
- it 'supports a groups column' do
66
- expect(subject.to_s).to eq("gem_a,1.0,\"development,production\"\n")
67
- end
68
- end
69
- end
70
- end
@@ -1,56 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module LicenseFinder
4
- describe DiffReport do
5
- describe '#to_s' do
6
- context 'reports from a single project' do
7
- it 'should generate a diff report' do
8
- foo = Package.new('foo', '1.0.0', spec_licenses: ['MIT'])
9
-
10
- bar = Package.new('bar', '1.1.0', spec_licenses: ['GPLv2'])
11
-
12
- foo_change = PackageDelta.added(foo)
13
- bar_change = PackageDelta.removed(bar)
14
-
15
- report = DiffReport.new([foo_change, bar_change])
16
- expect(report.to_s).to include('removed,bar,1.1.0,GPLv2')
17
- expect(report.to_s).to include('added,foo,1.0.0,MIT')
18
- end
19
-
20
- it 'should generate a diff report displaying version changes' do
21
- foo_old = Package.new('foo', '1.0.0', spec_licenses: ['MIT'])
22
-
23
- foo_new = Package.new('foo', '1.1.0', spec_licenses: ['MIT'])
24
-
25
- foo = PackageDelta.unchanged(foo_new, foo_old)
26
-
27
- report = DiffReport.new([foo])
28
- expect(report.to_s).to include('unchanged,foo,1.1.0,MIT')
29
- end
30
- end
31
-
32
- context 'reports from subprojects' do
33
- it 'should generate a diff report displaying source path' do
34
- project1_foo_old = Package.new('foo', '1.0.0', spec_licenses: ['MIT'])
35
- project1_foo_new = Package.new('foo', '1.1.0', spec_licenses: ['MIT'])
36
-
37
- project1_bar_new = Package.new('bar', '1.1.0', spec_licenses: ['MIT'])
38
- merged_foo_old = MergedPackage.new(project1_foo_old, ['path/to/project1'])
39
- merged_foo_new = MergedPackage.new(project1_foo_new, ['path/to/project1'])
40
- merged_bar_new = MergedPackage.new(project1_bar_new, ['path/to/project1', 'path/to/project2'])
41
-
42
- foo = PackageDelta.unchanged(merged_foo_new, merged_foo_old)
43
- bar = PackageDelta.added(merged_bar_new)
44
- expanded_foo_path = File.expand_path(merged_foo_old.subproject_paths[0])
45
- expanded_bar_path1 = File.expand_path(merged_bar_new.subproject_paths[0])
46
- expanded_bar_path2 = File.expand_path(merged_bar_new.subproject_paths[1])
47
-
48
-
49
- report = DiffReport.new([foo, bar])
50
- expect(report.to_s).to include("unchanged,foo,1.1.0,MIT,#{expanded_foo_path}")
51
- expect(report.to_s).to include("added,bar,1.1.0,MIT,\"#{expanded_bar_path1},#{expanded_bar_path2}\"")
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,101 +0,0 @@
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 = Package.new("the-dep")
9
- dep.decide_on_license License.find_by_name("MIT")
10
- dep
11
- end
12
- let(:dependencies) { [dependency] }
13
-
14
- subject { Capybara.string(HtmlReport.new(dependencies, project_name: "project name").to_s) }
15
-
16
- it "should show the project name" do
17
- title = subject.find "h1"
18
- expect(title).to have_text "project name"
19
- end
20
-
21
- context "when the dependency is manually approved" do
22
- before { dependency.approved_manually!(Decisions::TXN.new("the-approver", "the-approval-note", Time.now.utc)) }
23
-
24
- it "should show approved dependencies without action items" do
25
- is_expected.to have_selector ".approved"
26
- is_expected.not_to have_selector ".action-items"
27
- end
28
-
29
- it "shows the license, approver and approval notes" do
30
- deps = subject.find ".dependencies"
31
- expect(deps).to have_content "MIT"
32
- expect(deps).to have_content "the-approver"
33
- expect(deps).to have_content "the-approval-note"
34
- expect(deps).to have_selector "time"
35
- end
36
- end
37
-
38
- context "when the dependency is whitelisted" do
39
- before { dependency.whitelisted! }
40
-
41
- it "should show approved dependencies without action items" do
42
- is_expected.to have_selector ".approved"
43
- is_expected.not_to have_selector ".action-items"
44
- end
45
-
46
- it "shows the license" do
47
- deps = subject.find ".dependencies"
48
- expect(deps).to have_content "MIT"
49
- end
50
- end
51
-
52
- context "when the dependency is not approved" do
53
- it "should show unapproved dependencies with action items" do
54
- is_expected.to have_selector ".unapproved"
55
- is_expected.to have_selector ".action-items li"
56
- end
57
- end
58
-
59
- context "when the gem has a group" do
60
- let(:dependency) do
61
- Package.new(nil, nil, groups: ["foo group"])
62
- end
63
-
64
- it "should show the group" do
65
- is_expected.to have_text "(foo group)"
66
- end
67
- end
68
-
69
- context "when the gem does not have a group" do
70
- it "should not show the group" do
71
- is_expected.not_to have_text "()"
72
- end
73
- end
74
-
75
- context "when the gem has many relationships" do
76
- let(:dependencies) do
77
- grandparent = Package.new("foo grandparent", nil, children: ["foo parent"])
78
- parent = Package.new("foo parent", nil, children: ["foo child"])
79
- child = Package.new("foo child")
80
- pm = PackageManager.new
81
- allow(pm).to receive(:current_packages) { [grandparent, parent, child] }
82
- pm.current_packages_with_relations
83
- end
84
-
85
- it "should show the relationships" do
86
- is_expected.to have_text "foo parent is required by:"
87
- is_expected.to have_text "foo grandparent"
88
- is_expected.to have_text "foo parent relies on:"
89
- is_expected.to have_text "foo child"
90
- end
91
- end
92
-
93
- context "when the gem has no relationships" do
94
- it "should not show any relationships" do
95
- is_expected.not_to have_text "is required by:"
96
- is_expected.not_to have_text "relies on:"
97
- end
98
- end
99
- end
100
- end
101
- end
@@ -1,45 +0,0 @@
1
- require "spec_helper"
2
-
3
- module LicenseFinder
4
- describe MarkdownReport do
5
- describe '#to_s' do
6
- let(:dep1) do
7
- Package.new('gem_a', '1.0')
8
- end
9
-
10
- let(:dep2) do
11
- result = Package.new('gem_b', '2.3')
12
- result.decide_on_license(License.find_by_name('BSD'))
13
- result.approved_manually!(double(:approval).as_null_object)
14
- result
15
- end
16
-
17
- subject { MarkdownReport.new([dep2, dep1], project_name: "new_project_name").to_s }
18
-
19
- it 'should have the correct header' do
20
- is_expected.to match "# new_project_name"
21
- end
22
-
23
- it 'should list the total, and unapproved counts' do
24
- is_expected.to match "2 total"
25
- is_expected.to match /1 \*unapproved\*/
26
- end
27
-
28
- it "should list the unapproved dependency" do
29
- is_expected.to match 'href="#gem_a"'
30
- end
31
-
32
- it "should display a summary" do
33
- is_expected.to match "## Summary"
34
- is_expected.to match /\s+\* 1 unknown/
35
- is_expected.to match /\s+\* 1 BSD/
36
- end
37
-
38
- it "should list both gems" do
39
- is_expected.to match "## Items"
40
- is_expected.to match "### gem_a v1.0"
41
- is_expected.to match "### gem_b v2.3"
42
- end
43
- end
44
- end
45
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module LicenseFinder
4
- describe MergedReport do
5
- describe '#to_s' do
6
- it 'displays the path to the dependency' do
7
- foo = Package.new('foo', '1.0.0', spec_licenses: ['MIT'])
8
- bar = Package.new('bar', '2.0.0', spec_licenses: ['GPLv2'])
9
-
10
- merged_foo = MergedPackage.new(foo, ['path/to/foo'])
11
- merged_bar = MergedPackage.new(bar, ['path/to/bar'])
12
- expanded_foo_path = File.expand_path(merged_foo.subproject_paths[0])
13
- expanded_bar_path = File.expand_path(merged_bar.subproject_paths[0])
14
-
15
- report = MergedReport.new([merged_foo, merged_bar])
16
- expect(report.to_s).to include("foo,1.0.0,MIT,#{expanded_foo_path}")
17
- expect(report.to_s).to include("bar,2.0.0,GPLv2,#{expanded_bar_path}")
18
- end
19
- end
20
- end
21
- end
@@ -1,43 +0,0 @@
1
- require "spec_helper"
2
-
3
- module LicenseFinder
4
- describe TextReport do
5
- describe '#to_s' do
6
- let(:dep1) do
7
- result = Package.new('gem_a', '1.0')
8
- result.decide_on_license(License.find_by_name('MIT'))
9
- result
10
- end
11
-
12
- let(:dep2) do
13
- result = Package.new('gem_b', '1.0')
14
- result.decide_on_license(License.find_by_name('MIT'))
15
- result
16
- end
17
-
18
- let(:dep3) do
19
- result = Package.new('gem_c', '2.0')
20
- result.decide_on_license(License.find_by_name('MIT'))
21
- result.decide_on_license(License.find_by_name('BSD'))
22
- result
23
- end
24
-
25
- subject { described_class.new([dep3, dep2, dep1]).to_s }
26
-
27
- it 'should generate a text report with the name, version and license of each dependency, sorted by name' do
28
- is_expected.to eq("gem_a, 1.0, MIT\ngem_b, 1.0, MIT\ngem_c, 2.0, \"MIT, BSD\"\n")
29
- end
30
-
31
- it 'should generate a text report with the name, version of each dependency, use --columns option' do
32
- report = described_class.new([dep3, dep2, dep1], columns: %w[name version]).to_s
33
- expect(report).to eq("gem_a, 1.0\ngem_b, 1.0\ngem_c, 2.0\n")
34
- end
35
-
36
- it 'prints a warning message for packages that have not been installed' do
37
- dep = Package.new('gem_d', '2.0', missing: true)
38
- report = described_class.new([dep]).to_s
39
- expect(report).to eq("gem_d, 2.0, \"This package is not installed. Please install to determine licenses.\"\n")
40
- end
41
- end
42
- end
43
- end
data/spec/spec_helper.rb DELETED
@@ -1,27 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'license_finder'
4
-
5
- require 'pry'
6
- require 'rspec'
7
- require 'webmock/rspec'
8
- require 'rspec/its'
9
-
10
- Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each do |file|
11
- require file
12
- end
13
-
14
- RSpec.configure do |config|
15
- config.mock_with :rspec
16
- end
17
-
18
- RSpec.configure do |config|
19
- config.after(:suite) do
20
- ["./doc"].each do |tmp_dir|
21
- tmp_dir = Pathname(tmp_dir)
22
- tmp_dir.rmtree if tmp_dir.directory?
23
- end
24
- end
25
-
26
- config.include LicenseFinder::TestFixtures
27
- end