license_finder 1.1.1-java → 1.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/CHANGELOG.rdoc +10 -0
  4. data/Gemfile +1 -1
  5. data/README.md +363 -0
  6. data/Rakefile +30 -1
  7. data/TODO.md +28 -0
  8. data/bin/license_finder_pip.py +18 -0
  9. data/db/migrate/201410031451_rename_dependency_license_name.rb +6 -0
  10. data/features/multiple_licenses.feature +9 -0
  11. data/features/step_definitions/cli_steps.rb +9 -9
  12. data/features/step_definitions/cocoapod_steps.rb +1 -1
  13. data/features/step_definitions/configure_bundler_groups_steps.rb +3 -3
  14. data/features/step_definitions/configure_whitelist_steps.rb +4 -4
  15. data/features/step_definitions/gradle_steps.rb +1 -1
  16. data/features/step_definitions/manually_added_steps.rb +3 -3
  17. data/features/step_definitions/manually_approved_steps.rb +5 -5
  18. data/features/step_definitions/manually_assigned_license_steps.rb +4 -4
  19. data/features/step_definitions/maven_steps.rb +1 -1
  20. data/features/step_definitions/multiple_licenses_steps.rb +14 -0
  21. data/features/step_definitions/node_steps.rb +1 -1
  22. data/features/step_definitions/python_steps.rb +1 -1
  23. data/features/step_definitions/report_csv_steps.rb +3 -3
  24. data/features/step_definitions/report_html_steps.rb +5 -5
  25. data/features/step_definitions/shared_steps.rb +23 -6
  26. data/lib/license_finder.rb +3 -0
  27. data/lib/license_finder/cli.rb +13 -34
  28. data/lib/license_finder/configuration.rb +8 -4
  29. data/lib/license_finder/dependency_manager.rb +25 -15
  30. data/lib/license_finder/license.rb +8 -0
  31. data/lib/license_finder/logger.rb +59 -0
  32. data/lib/license_finder/package.rb +37 -30
  33. data/lib/license_finder/package_manager.rb +20 -0
  34. data/lib/license_finder/package_managers/bower.rb +4 -9
  35. data/lib/license_finder/package_managers/bower_package.rb +2 -1
  36. data/lib/license_finder/package_managers/bundler.rb +26 -41
  37. data/lib/license_finder/package_managers/bundler_package.rb +6 -3
  38. data/lib/license_finder/package_managers/cocoa_pods.rb +18 -10
  39. data/lib/license_finder/package_managers/cocoa_pods_package.rb +4 -3
  40. data/lib/license_finder/package_managers/gradle.rb +7 -11
  41. data/lib/license_finder/package_managers/gradle_package.rb +2 -7
  42. data/lib/license_finder/package_managers/maven.rb +5 -9
  43. data/lib/license_finder/package_managers/maven_package.rb +4 -8
  44. data/lib/license_finder/package_managers/npm.rb +6 -10
  45. data/lib/license_finder/package_managers/npm_package.rb +2 -1
  46. data/lib/license_finder/package_managers/pip.rb +11 -24
  47. data/lib/license_finder/package_managers/pip_package.rb +2 -1
  48. data/lib/license_finder/package_saver.rb +2 -2
  49. data/lib/license_finder/platform.rb +4 -0
  50. data/lib/license_finder/possible_license_file.rb +4 -0
  51. data/lib/license_finder/possible_license_files.rb +2 -1
  52. data/lib/license_finder/reports/detailed_text_report.rb +1 -1
  53. data/lib/license_finder/reports/formatted_report.rb +1 -1
  54. data/lib/license_finder/tables/dependency.rb +22 -12
  55. data/lib/license_finder/yml_to_sql.rb +1 -1
  56. data/lib/templates/html_report.erb +4 -4
  57. data/lib/templates/markdown_report.erb +4 -4
  58. data/lib/templates/text_report.erb +1 -1
  59. data/license_finder.gemspec +28 -12
  60. data/spec/lib/license_finder/cli_spec.rb +193 -185
  61. data/spec/lib/license_finder/configuration_spec.rb +46 -47
  62. data/spec/lib/license_finder/dependency_manager_spec.rb +48 -44
  63. data/spec/lib/license_finder/license/definitions_spec.rb +26 -26
  64. data/spec/lib/license_finder/license_spec.rb +25 -25
  65. data/spec/lib/license_finder/package_managers/bower_package_spec.rb +33 -17
  66. data/spec/lib/license_finder/package_managers/bower_spec.rb +35 -35
  67. data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +20 -15
  68. data/spec/lib/license_finder/package_managers/bundler_spec.rb +12 -19
  69. data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +8 -5
  70. data/spec/lib/license_finder/package_managers/cocoa_pods_spec.rb +20 -22
  71. data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +8 -5
  72. data/spec/lib/license_finder/package_managers/gradle_spec.rb +20 -20
  73. data/spec/lib/license_finder/package_managers/maven_package_spec.rb +8 -5
  74. data/spec/lib/license_finder/package_managers/maven_spec.rb +18 -18
  75. data/spec/lib/license_finder/package_managers/npm_package_spec.rb +36 -17
  76. data/spec/lib/license_finder/package_managers/npm_spec.rb +17 -17
  77. data/spec/lib/license_finder/package_managers/pip_package_spec.rb +16 -10
  78. data/spec/lib/license_finder/package_managers/pip_spec.rb +21 -18
  79. data/spec/lib/license_finder/package_saver_spec.rb +15 -25
  80. data/spec/lib/license_finder/possible_license_file_spec.rb +5 -4
  81. data/spec/lib/license_finder/possible_license_files_spec.rb +11 -5
  82. data/spec/lib/license_finder/reports/detailed_text_report_spec.rb +3 -3
  83. data/spec/lib/license_finder/reports/html_report_spec.rb +23 -23
  84. data/spec/lib/license_finder/reports/markdown_report_spec.rb +12 -12
  85. data/spec/lib/license_finder/reports/reporter_spec.rb +11 -11
  86. data/spec/lib/license_finder/reports/text_report_spec.rb +3 -3
  87. data/spec/lib/license_finder/tables/dependency_spec.rb +59 -41
  88. data/spec/lib/license_finder/yml_to_sql_spec.rb +21 -21
  89. data/spec/lib/license_finder_spec.rb +1 -1
  90. data/spec/spec_helper.rb +0 -13
  91. data/spec/support/shared_examples_for_package.rb +46 -0
  92. data/spec/support/shared_examples_for_package_manager.rb +15 -0
  93. metadata +19 -100
  94. data/readme.md +0 -259
@@ -2,6 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  module LicenseFinder
4
4
  describe NPM do
5
+ let(:npm) { NPM.new }
6
+ it_behaves_like "a PackageManager"
7
+
5
8
  describe '.current_packages' do
6
9
  before { NPM.instance_variable_set(:@modules, nil) }
7
10
 
@@ -62,9 +65,9 @@ module LicenseFinder
62
65
  }
63
66
  }
64
67
  JSON
65
- allow(NPM).to receive(:capture).with(/npm/).and_return([json, true])
68
+ allow(npm).to receive(:capture).with(/npm/).and_return([json, true])
66
69
 
67
- current_packages = NPM.current_packages
70
+ current_packages = npm.current_packages
68
71
 
69
72
  expect(current_packages.map(&:name)).to eq(["depjs", "dep2js", "dep3js", "dep5js", "dep4js"])
70
73
  expect(current_packages.first).to be_a(Package)
@@ -79,39 +82,36 @@ module LicenseFinder
79
82
  }
80
83
  }
81
84
  JSON
82
- allow(NPM).to receive(:capture).with(/npm/).and_return([json, true])
85
+ allow(npm).to receive(:capture).with(/npm/).and_return([json, true])
83
86
 
84
- current_packages = NPM.current_packages
87
+ current_packages = npm.current_packages
85
88
 
86
89
  expect(current_packages.map(&:name)).to eq([])
87
90
  end
88
91
 
89
92
  it "fails when command fails" do
90
- allow(NPM).to receive(:capture).with(/npm/).and_return('Some error', false).once
91
- expect { NPM.current_packages }.to raise_error(RuntimeError)
93
+ allow(npm).to receive(:capture).with(/npm/).and_return('Some error', false).once
94
+ expect { npm.current_packages }.to raise_error(RuntimeError)
92
95
  end
93
96
 
94
97
  it "does not fail when command fails but produces output" do
95
- allow(NPM).to receive(:capture).with(/npm/).and_return('{"foo":"bar"}', false).once
96
- NPM.current_packages
98
+ allow(npm).to receive(:capture).with(/npm/).and_return('{"foo":"bar"}', false).once
99
+ npm.current_packages
97
100
  end
98
101
  end
99
102
 
100
103
  describe '.active?' do
101
- let(:package) { double(:package_file) }
102
-
103
- before do
104
- NPM.stub(package_path: package)
105
- end
104
+ let(:package_path) { double(:package_file) }
105
+ let(:npm) { NPM.new package_path: package_path }
106
106
 
107
107
  it 'is true with a package.json file' do
108
- package.stub(:exist? => true)
109
- expect(NPM).to be_active
108
+ allow(package_path).to receive_messages(:exist? => true)
109
+ expect(npm).to be_active
110
110
  end
111
111
 
112
112
  it 'is false without a package.json file' do
113
- package.stub(:exist? => false)
114
- expect(NPM).to_not be_active
113
+ allow(package_path).to receive_messages(:exist? => false)
114
+ expect(npm).to_not be_active
115
115
  end
116
116
  end
117
117
  end
@@ -4,7 +4,7 @@ module LicenseFinder
4
4
  describe PipPackage do
5
5
  subject { make_package({}) }
6
6
 
7
- it_behaves_like "it conforms to interface required by PackageSaver"
7
+ it_behaves_like "a Package"
8
8
 
9
9
  def make_package(pypi_def)
10
10
  described_class.new('jasmine', '1.3.1', "jasmine/install/path", pypi_def)
@@ -49,14 +49,15 @@ module LicenseFinder
49
49
  end
50
50
  end
51
51
 
52
- describe '#license' do
52
+ describe '#licenses' do
53
53
  describe "with valid pypi license" do
54
54
  it "returns the license from 'license' preferentially" do
55
55
  data = { "license" => "MIT", "classifiers" => [ 'License :: OSI Approved :: Apache 2.0 License' ] }
56
56
 
57
57
  subject = make_package(data)
58
58
 
59
- expect(subject.license.name).to eq('MIT')
59
+ expect(subject.licenses.length).to eq 1
60
+ expect(subject.licenses.first.name).to eq('MIT')
60
61
  end
61
62
 
62
63
  context "when there's no explicit license" do
@@ -65,7 +66,8 @@ module LicenseFinder
65
66
 
66
67
  subject = make_package(data)
67
68
 
68
- expect(subject.license.name).to eq('Apache 2.0 License')
69
+ expect(subject.licenses.length).to eq 1
70
+ expect(subject.licenses.first.name).to eq('Apache 2.0 License')
69
71
  end
70
72
 
71
73
  it "returns 'multiple licenses' if there are multiple licenses in 'classifiers'" do
@@ -73,7 +75,8 @@ module LicenseFinder
73
75
 
74
76
  subject = make_package(data)
75
77
 
76
- expect(subject.license.name).to eq('multiple licenses: Apache 2.0 License, GPL')
78
+ expect(subject.licenses.length).to eq 2
79
+ expect(subject.licenses.map(&:name)).to eq ['Apache 2.0 License', 'GPL']
77
80
  end
78
81
  end
79
82
 
@@ -84,7 +87,8 @@ module LicenseFinder
84
87
 
85
88
  subject = make_package(data)
86
89
 
87
- expect(subject.license.name).to eq('Apache 2.0 License')
90
+ expect(subject.licenses.length).to eq 1
91
+ expect(subject.licenses.first.name).to eq('Apache 2.0 License')
88
92
  end
89
93
  end
90
94
  end
@@ -92,17 +96,19 @@ module LicenseFinder
92
96
 
93
97
  describe "without pypi license" do
94
98
  def stub_license_files(license_files)
95
- PossibleLicenseFiles.stub(:find).with("jasmine/install/path").and_return(license_files)
99
+ allow(PossibleLicenseFiles).to receive(:find).with("jasmine/install/path").and_return(license_files)
96
100
  end
97
101
 
98
102
  it 'returns license from file' do
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')
103
+ stub_license_files [double(:license_file, license: License.find_by_name('License from file'), path: "/")]
104
+ expect(subject.licenses.length).to eq 1
105
+ expect(subject.licenses.first.name).to eq('License from file')
101
106
  end
102
107
 
103
108
  it 'returns other if no license can be found' do
104
109
  stub_license_files []
105
- expect(subject.license.name).to eq('other')
110
+ expect(subject.licenses.length).to eq 1
111
+ expect(subject.licenses.first.name).to eq('other')
106
112
  end
107
113
  end
108
114
  end
@@ -2,9 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  module LicenseFinder
4
4
  describe Pip do
5
+ let(:pip) { Pip.new }
6
+ it_behaves_like "a PackageManager"
7
+
5
8
  describe '.current_packages' do
6
9
  def stub_pip(stdout)
7
- allow(Pip).to receive(:`).with(/python/).and_return(stdout)
10
+ allow(pip).to receive("`").with(/license_finder_pip.py/).and_return(stdout)
8
11
  end
9
12
 
10
13
  def stub_pypi(name, version, response)
@@ -13,48 +16,48 @@ module LicenseFinder
13
16
  end
14
17
 
15
18
  it 'fetches data from pip' do
16
- stub_pip('[["jasmine", "1.3.1", "jasmine/path"], ["jasmine-core", "1.3.1", "jasmine-core/path"]]')
19
+ stub_pip [
20
+ {"name" => "jasmine", "version" => "1.3.1", "location" => "jasmine/path"},
21
+ {"name" => "jasmine-core", "version" => "1.3.1", "location" => "jasmine-core/path"}
22
+ ].to_json
17
23
  stub_pypi("jasmine", "1.3.1", status: 200, body: '{}')
18
24
  stub_pypi("jasmine-core", "1.3.1", status: 200, body: '{}')
19
25
 
20
- current_packages = Pip.current_packages
26
+ current_packages = pip.current_packages
21
27
 
22
28
  expect(current_packages.size).to eq(2)
23
29
  expect(current_packages.first).to be_a(Package)
24
30
  end
25
31
 
26
32
  it "fetches data from pypi" do
27
- stub_pip('[["jasmine", "1.3.1", "jasmine/path"]]')
33
+ stub_pip [{"name" => "jasmine", "version" => "1.3.1", "location" => "jasmine/path"}].to_json
28
34
  stub_pypi("jasmine", "1.3.1", status: 200, body: JSON.generate(info: {summary: "A summary"}))
29
35
 
30
- expect(PipPackage).to receive(:new).with("jasmine", "1.3.1", "jasmine/path/jasmine", "summary" => "A summary")
31
- Pip.current_packages
36
+ expect(PipPackage).to receive(:new).with("jasmine", "1.3.1", "jasmine/path/jasmine", {"summary" => "A summary"}, anything)
37
+ pip.current_packages
32
38
  end
33
39
 
34
40
  it "ignores pypi if it can't find useful info" do
35
- stub_pip('[["jasmine", "1.3.1", "jasmine/path"]]')
41
+ stub_pip [{"name" => "jasmine", "version" => "1.3.1", "location" => "jasmine/path"}].to_json
36
42
  stub_pypi("jasmine", "1.3.1", status: 404, body: '')
37
43
 
38
- expect(PipPackage).to receive(:new).with("jasmine", "1.3.1", "jasmine/path/jasmine", {})
39
- Pip.current_packages
44
+ expect(PipPackage).to receive(:new).with("jasmine", "1.3.1", "jasmine/path/jasmine", {}, anything)
45
+ pip.current_packages
40
46
  end
41
47
  end
42
48
 
43
49
  describe '.active?' do
44
- let(:requirements) { double(:requirements_file) }
45
-
46
- before do
47
- Pip.stub(requirements_path: requirements)
48
- end
50
+ let(:package_path) { double(:requirements_file) }
51
+ let(:pip) { Pip.new package_path: package_path }
49
52
 
50
53
  it 'is true with a requirements.txt file' do
51
- requirements.stub(:exist? => true)
52
- expect(Pip).to be_active
54
+ allow(package_path).to receive_messages(:exist? => true)
55
+ expect(pip).to be_active
53
56
  end
54
57
 
55
58
  it 'is false without a requirements.txt file' do
56
- requirements.stub(:exist? => false)
57
- expect(Pip).to_not be_active
59
+ allow(package_path).to receive_messages(:exist? => false)
60
+ expect(pip).to_not be_active
58
61
  end
59
62
  end
60
63
  end
@@ -5,7 +5,7 @@ module LicenseFinder
5
5
  let(:package) do
6
6
  double(
7
7
  :package,
8
- license: License.find_by_name('license'),
8
+ licenses: [License.find_by_name('license')].to_set,
9
9
  children: ['child'],
10
10
  groups: [:group],
11
11
  summary: 'summary',
@@ -20,8 +20,8 @@ module LicenseFinder
20
20
  let(:dependency) { double(:dependency).as_null_object }
21
21
 
22
22
  it "find and updates relevant dependencies" do
23
- Dependency.should_receive(:named).with('spec_name').and_return(dependency)
24
- dependency.should_receive(:save_changes)
23
+ expect(Dependency).to receive(:named).with('spec_name').and_return(dependency)
24
+ expect(dependency).to receive(:save_changes)
25
25
  described_class.save_all([package])
26
26
  end
27
27
  end
@@ -34,7 +34,7 @@ module LicenseFinder
34
34
  summary: 'old summary',
35
35
  description: 'old desription',
36
36
  homepage: 'old homepage',
37
- license_name: 'old license'
37
+ license_names: ["old license"].to_json
38
38
  )
39
39
  dep.add_bundler_group BundlerGroup.named("old group")
40
40
  dep.add_child Dependency.named("old child")
@@ -42,15 +42,15 @@ module LicenseFinder
42
42
  saver = described_class.new(dep, package)
43
43
  subject = saver.save
44
44
 
45
- subject.id.should be
46
- subject.name.should == "spec_name"
47
- subject.version.should == "1.2.3"
48
- subject.summary.should == "summary"
49
- subject.description.should == "description"
50
- subject.homepage.should == "http://example.com"
51
- subject.bundler_groups.map(&:name).should == ['group']
52
- subject.children.map(&:name).should == ['child']
53
- subject.license.name.should == 'license'
45
+ expect(subject.id).to be
46
+ expect(subject.name).to eq("spec_name")
47
+ expect(subject.version).to eq("1.2.3")
48
+ expect(subject.summary).to eq("summary")
49
+ expect(subject.description).to eq("description")
50
+ expect(subject.homepage).to eq("http://example.com")
51
+ expect(subject.bundler_groups.map(&:name)).to eq(['group'])
52
+ expect(subject.children.map(&:name)).to eq(['child'])
53
+ expect(subject.licenses.first.name).to eq('license')
54
54
  end
55
55
 
56
56
  it "keeps approval" do
@@ -61,7 +61,7 @@ module LicenseFinder
61
61
  saver = described_class.new(dep, package)
62
62
  subject = saver.save
63
63
 
64
- subject.should be_approved
64
+ expect(subject).to be_approved
65
65
  end
66
66
 
67
67
  context "to minimize db changes" do
@@ -69,23 +69,13 @@ module LicenseFinder
69
69
  # See note in PackageSaver#save
70
70
 
71
71
  first_run = described_class.find_or_create_by_name(package)
72
- # Can't set this expectation, because rspec method expectations
73
- # have no way to allow the real save to happen.
74
- # expect(first_run.dependency).to receive(:save)
72
+ expect(first_run.dependency).to receive(:save).and_call_original
75
73
  first_run.save
76
74
 
77
75
  second_run = described_class.find_or_create_by_name(package)
78
76
  expect(second_run.dependency).to_not receive(:save)
79
77
  second_run.save
80
78
  end
81
-
82
- it "saves new dependencies" do
83
- # Just a sanity check that the above test is testing what we think it
84
- # is testing.
85
- saver = described_class.find_or_create_by_name(package)
86
- expect(saver.dependency).to receive(:save)
87
- saver.save
88
- end
89
79
  end
90
80
  end
91
81
  end
@@ -7,11 +7,12 @@ module LicenseFinder
7
7
 
8
8
  context "ignoring text" do
9
9
  before do
10
- subject.stub(:text).and_return('file text')
10
+ allow(subject).to receive(:text).and_return('file text')
11
11
  end
12
12
 
13
13
  its(:file_path) { should == 'nested/path' }
14
14
  its(:text) { should == 'file text' } # this is a terrible test, considering the stubbing
15
+ its(:path) { should == 'root/nested/path' }
15
16
  end
16
17
  end
17
18
 
@@ -19,9 +20,9 @@ module LicenseFinder
19
20
 
20
21
  context "with a known license" do
21
22
  before do
22
- subject.stub(:text).and_return('a known license')
23
+ allow(subject).to receive(:text).and_return('a known license')
23
24
 
24
- License.stub(:find_by_text).with('a known license').and_return(License.find_by_name("MIT"))
25
+ allow(License).to receive(:find_by_text).with('a known license').and_return(License.find_by_name("MIT"))
25
26
  end
26
27
 
27
28
  its(:license) { should == License.find_by_name("MIT") }
@@ -29,7 +30,7 @@ module LicenseFinder
29
30
 
30
31
  context "with an unknown license" do
31
32
  before do
32
- subject.stub(:text).and_return('')
33
+ allow(subject).to receive(:text).and_return('')
33
34
  end
34
35
 
35
36
  its(:license) { should be_nil }
@@ -7,36 +7,42 @@ module LicenseFinder
7
7
  end
8
8
 
9
9
  describe "#find" do
10
+ it "is empty if passed a nil install path" do
11
+ subject = described_class.new nil
12
+ expect(subject.find).to eq([])
13
+ end
14
+
10
15
  it "is empty if there aren't any license files" do
11
16
  subject = described_class.new('/not/a/dir')
12
- subject.find.should == []
17
+ expect(subject.find).to eq([])
13
18
  end
14
19
 
15
20
  it "includes files with names like LICENSE, License or COPYING" do
16
21
  subject = described_class.new(fixture_path('license_names'))
17
22
 
18
- subject.find.map(&:file_path).should =~
23
+ expect(subject.find.map(&:file_path)).to match_array(
19
24
  %w[COPYING.txt LICENSE Mit-License README.rdoc Licence.rdoc]
25
+ )
20
26
  end
21
27
 
22
28
  it "includes files deep in the hierarchy" do
23
29
  subject = described_class.new(fixture_path('nested_gem'))
24
30
 
25
- subject.find.map(&:file_path).should =~ %w[vendor/LICENSE]
31
+ expect(subject.find.map(&:file_path)).to match_array(%w[vendor/LICENSE])
26
32
  end
27
33
 
28
34
  it "includes both files nested inside LICENSE directory and top level files" do
29
35
  subject = described_class.new(fixture_path('license_directory'))
30
36
  found_license_files = subject.find
31
37
 
32
- found_license_files.map(&:file_path).should =~ %w[
38
+ expect(found_license_files.map(&:file_path)).to match_array(%w[
33
39
  LICENSE/BSD-2-Clause.txt
34
40
  LICENSE/GPL-2.0.txt
35
41
  LICENSE/MIT.txt
36
42
  LICENSE/RUBY.txt
37
43
  COPYING
38
44
  LICENSE/LICENSE
39
- ]
45
+ ])
40
46
  end
41
47
 
42
48
  it "handles non UTF8 encodings" do
@@ -9,7 +9,7 @@ module LicenseFinder
9
9
  'version' => '1.0',
10
10
  'summary' => 'Summary',
11
11
  'description' => 'Description',
12
- 'license' => License.find_by_name('MIT')
12
+ 'licenses' => [License.find_by_name('MIT')].to_set
13
13
  )
14
14
  end
15
15
 
@@ -19,14 +19,14 @@ module LicenseFinder
19
19
  'version' => '1.0',
20
20
  'summary' => 'Summary',
21
21
  'description' => 'Description',
22
- 'license' => License.find_by_name('MIT')
22
+ 'licenses' => [License.find_by_name('MIT')].to_set
23
23
  )
24
24
  end
25
25
 
26
26
  subject { DetailedTextReport.new([dep2, dep1]).to_s }
27
27
 
28
28
  it 'should generate a text report with the name, version, license, summary and description of each dependency, sorted by name' do
29
- should == "gem_a,1.0,MIT,Summary,Description\ngem_b,1.0,MIT,Summary,Description\n"
29
+ is_expected.to eq("gem_a,1.0,MIT,Summary,Description\ngem_b,1.0,MIT,Summary,Description\n")
30
30
  end
31
31
  end
32
32
  end
@@ -7,7 +7,7 @@ module LicenseFinder
7
7
  let(:dependency_name) { "the-name" }
8
8
  let(:dependency) do
9
9
  dep = Dependency.create name: dependency_name
10
- dep.apply_better_license License.find_by_name("MIT")
10
+ dep.set_licenses [License.find_by_name("MIT")].to_set
11
11
  dep
12
12
  end
13
13
 
@@ -17,66 +17,66 @@ module LicenseFinder
17
17
  before { dependency.approve! "the-approver", "the-approval-note" }
18
18
 
19
19
  it "should show approved dependencies without action items" do
20
- should have_selector ".approved"
21
- should_not have_selector ".action-items"
20
+ is_expected.to have_selector ".approved"
21
+ is_expected.not_to have_selector ".action-items"
22
22
  end
23
23
 
24
24
  it "shows the license, approver and approval notes" do
25
25
  deps = subject.find ".dependencies"
26
- deps.should have_content "MIT"
27
- deps.should have_content "the-approver"
28
- deps.should have_content "the-approval-note"
29
- deps.should have_selector "time"
26
+ expect(deps).to have_content "MIT"
27
+ expect(deps).to have_content "the-approver"
28
+ expect(deps).to have_content "the-approval-note"
29
+ expect(deps).to have_selector "time"
30
30
  end
31
31
  end
32
32
 
33
33
  context "when the dependency is whitelisted" do
34
- before { dependency.stub(whitelisted?: true) }
34
+ before { allow(dependency).to receive_messages(whitelisted?: true) }
35
35
 
36
36
  it "should show approved dependencies without action items" do
37
- should have_selector ".approved"
38
- should_not have_selector ".action-items"
37
+ is_expected.to have_selector ".approved"
38
+ is_expected.not_to have_selector ".action-items"
39
39
  end
40
40
 
41
41
  it "shows the license" do
42
42
  deps = subject.find ".dependencies"
43
- deps.should have_content "MIT"
43
+ expect(deps).to have_content "MIT"
44
44
  end
45
45
  end
46
46
 
47
47
  context "when the dependency is not approved" do
48
48
  before {
49
- dependency.license = License.find_by_name('GPL')
49
+ dependency.licenses = [License.find_by_name('GPL')].to_set
50
50
  dependency.manual_approval = nil
51
51
  }
52
52
 
53
53
  it "should show unapproved dependencies with action items" do
54
- should have_selector ".unapproved"
55
- should have_selector ".action-items li"
54
+ is_expected.to have_selector ".unapproved"
55
+ is_expected.to have_selector ".action-items li"
56
56
  end
57
57
  end
58
58
 
59
59
  context "when the gem has many relationships" do
60
60
  before do
61
- dependency.stub(bundler_groups: [double(name: "foo group")],
61
+ allow(dependency).to receive_messages(bundler_groups: [double(name: "foo group")],
62
62
  parents: [double(name: "foo parent")],
63
63
  children: [double(name: "foo child")])
64
64
  end
65
65
 
66
66
  it "should show the relationships" do
67
- should have_text "(foo group)"
68
- should have_text "#{dependency_name} is required by:"
69
- should have_text "foo parent"
70
- should have_text "#{dependency_name} relies on:"
71
- should have_text "foo child"
67
+ is_expected.to have_text "(foo group)"
68
+ is_expected.to have_text "#{dependency_name} is required by:"
69
+ is_expected.to have_text "foo parent"
70
+ is_expected.to have_text "#{dependency_name} relies on:"
71
+ is_expected.to have_text "foo child"
72
72
  end
73
73
  end
74
74
 
75
75
  context "when the gem has no relationships" do
76
76
  it "should not show any relationships" do
77
- should_not have_text "()"
78
- should_not have_text "#{dependency_name} is required by:"
79
- should_not have_text "#{dependency_name} relies on:"
77
+ is_expected.not_to have_text "()"
78
+ is_expected.not_to have_text "#{dependency_name} is required by:"
79
+ is_expected.not_to have_text "#{dependency_name} relies on:"
80
80
  end
81
81
  end
82
82
  end