require File.expand_path('../spec_helper.rb', __FILE__) describe ReportGenerator = CocoaPodsGitlabLicenseReport::ReportGenerator do before do @spec1 = SpecHelper.spec1 @spec2 = SpecHelper.spec2 @sandbox = temporary_sandbox allow(@sandbox).to receive(:manifest_path).and_return('/path/to/Podfile.lock') end it 'generates metadata' do result = ReportGenerator.new(@sandbox).generate([@spec1, @spec2], []) expect(result).to eq({ :version => "2.1", :licenses => [{ :id => 'Apache 2.0', :name => 'Apache 2.0', :url => "http://www.apache.org/licenses/LICENSE-2.0.txt"}, { :id => 'MIT', :name => 'MIT', :url => "http://opensource.org/licenses/mit-license"}], :dependencies => [{ :name => "monkeylib", :version => '1.0', :package_manager => "cocoapods", :path => "/path/to/Podfile.lock", :licenses => ['MIT'] }, { :name => "BananaLib", :version => '2.0', :package_manager => "cocoapods", :path => "/path/to/Podfile.lock", :licenses => ['Apache 2.0'] }] }) end it 'generates empty if specs is empty' do result = ReportGenerator.new(@sandbox).generate([], []) expect(result).to eq({ :version => "2.1", :licenses => [], :dependencies => [] }) end it 'does not include metadata for excluded specs' do result = ReportGenerator.new(@sandbox).generate([@spec1, @spec2], [@spec1.name]) expect(result).to eq({ :version => "2.1", :licenses => [{ :id => 'Apache 2.0', :name => 'Apache 2.0', :url => "http://www.apache.org/licenses/LICENSE-2.0.txt"}], :dependencies => [{ :name => "BananaLib", :version => '2.0', :package_manager => "cocoapods", :path => "/path/to/Podfile.lock", :licenses => ['Apache 2.0'] }] }) end end