Sha256: 879406deb0687e9364eb024b42df8ff6c02cfdc6dd00e75d4dd53eaf80d290f0

Contents?: true

Size: 1.9 KB

Versions: 4

Compression:

Stored size: 1.9 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 == "" }

    describe "#license" do
      it "returns the license if found" do
        subject.license.name.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 'multiple licenses'" do
          subject.license.name.should == 'multiple licenses: Common Public License Version 1.0, Apache 2'
        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.name.should == "other"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
license_finder-1.1.1-java spec/lib/license_finder/package_managers/maven_package_spec.rb
license_finder-1.1.1 spec/lib/license_finder/package_managers/maven_package_spec.rb
license_finder-1.1.0 spec/lib/license_finder/package_managers/maven_package_spec.rb
license_finder-1.0.1 spec/lib/license_finder/package_managers/maven_package_spec.rb