Sha256: bf0389fd6d148d62733cb28a9c833f7d7284d99f65cbe4fee16fb3dc55a23e0e

Contents?: true

Size: 1.89 KB

Versions: 2

Compression:

Stored size: 1.89 KB

Contents

require 'spec_helper'

module LicenseFinder
  describe MavenPackage do
    subject do
      described_class.new(
        {
          "groupId" => "org.hamcrest",
          "artifactId" => "hamcrest-core",
          "version" => "4.11",
          "licenses" => [{
              "name" => "Common Public License Version 1.0",
              "url" => "http://www.opensource.org/licenses/cpl1.0.txt"
          }]
        }
      )
    end

    it_behaves_like "it conforms to interface required by PackageSaver"

    its(:name) { should == "hamcrest-core" }
    its(:version) { should == "4.11" }
    its(:description) { should == "" }
    its(:licenses_from_spec) { should == ["Common Public License Version 1.0"] }

    describe "#license" do
      it "returns the license if found" do
        subject.license.should == "Common Public License Version 1.0"
      end

      context "when there are multiple licenses" do
        subject do
          described_class.new(
            {
              "groupId" => "org.hamcrest",
              "artifactId" => "hamcrest-core",
              "licenses" => [{
                "name" => "Common Public License Version 1.0",
                "url" => "http://www.opensource.org/licenses/cpl1.0.txt"
              },
              {
                "name" => "Apache 2",
                "url" => "http://www.apache.org/licenses/LICENSE-2.0.txt"
              }]
            }
          )
        end

        it "returns 'other'" do
          subject.license.should == 'other'
        end
      end

      context "when the license is not found" do
        subject do
          described_class.new(
            {
              "groupId" => "org.hamcrest",
              "artifactId" => "hamcrest-core",
              "licenses" => {}
             }
          )
        end

        it "returns 'other' otherwise" do
          subject.license.should == "other"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
license_finder-1.0.0.0 spec/lib/license_finder/package_managers/maven_package_spec.rb
license_finder-1.0.0.0-java spec/lib/license_finder/package_managers/maven_package_spec.rb