Sha256: cdf0d6ebadf3bc63681736d6b4708a90f82259fd043312da27ecdb3ecd2fb989

Contents?: true

Size: 1.17 KB

Versions: 9

Compression:

Stored size: 1.17 KB

Contents

RSpec.describe Licensee::LicenseRules do
  let(:mit) { Licensee::License.find('mit') }
  subject { mit.rules }

  Licensee::Rule.groups.each do |group|
    context "the #{group} rule group" do
      it 'responds as a hash key string' do
        expect(subject[group]).to be_a(Array)
      end

      it 'responds as a hash key symbol' do
        expect(subject[group.to_sym]).to be_a(Array)
      end

      it 'responds as a method' do
        expect(subject.public_send(group.to_sym)).to be_a(Array)
      end
    end
  end

  context 'created from a license' do
    subject { described_class.from_license(mit) }

    it 'exposes the rules' do
      expect(subject.permissions.first.label).to eql('Commercial use')
    end
  end

  context 'created from a meta' do
    subject { described_class.from_meta(mit.meta) }

    it 'exposes the rules' do
      expect(subject.permissions.first.label).to eql('Commercial use')
    end
  end

  context 'created from a hash' do
    let(:hash) { { 'permissions' => Licensee::Rule.all } }
    subject { described_class.from_hash(hash) }

    it 'exposes the rules' do
      expect(subject.permissions.first.label).to eql('Commercial use')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
licensee-9.8.0 spec/licensee/license_rules_spec.rb
licensee-9.7.0 spec/licensee/license_rules_spec.rb
licensee-9.6.0 spec/licensee/license_rules_spec.rb
licensee-9.5.0 spec/licensee/license_rules_spec.rb
licensee-9.4.0 spec/licensee/license_rules_spec.rb
licensee-9.3.1 spec/licensee/license_rules_spec.rb
licensee-9.3.0 spec/licensee/license_rules_spec.rb
licensee-9.2.1 spec/licensee/license_rules_spec.rb
licensee-9.2.0 spec/licensee/license_rules_spec.rb