Sha256: 435b1008131920dc2c141bee86b1808ccb4faa0485b23661015a993700b0c230

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

RSpec.describe Licensee::Rule do
  let(:groups) { %w(permissions conditions limitations) }

  it 'stores the properties' do
    rule = described_class.new(
      tag:         'tag',
      label:       'label',
      description: 'description',
      group:       'group'
    )

    expect(rule.tag).to eql('tag')
    expect(rule.label).to eql('label')
    expect(rule.description).to eql('description')
    expect(rule.group).to eql('group')
  end

  it 'loads the groups' do
    expect(described_class.groups).to eql(groups)
  end

  it 'loads the raw rules' do
    groups.each do |key|
      expect(described_class.raw_rules).to have_key(key)
    end
  end

  it 'determines the file path' do
    path = described_class.file_path
    expect(File.exist?(path)).to eql(true)
  end

  it 'loads a rule by tag' do
    rule = described_class.find_by_tag('commercial-use')
    expect(rule).to be_a(described_class)
    expect(rule.tag).to eql('commercial-use')
  end

  it 'loads a rule by tag and group' do
    rule = described_class.find_by_tag_and_group('patent-use', 'limitations')
    expect(rule).to be_a(described_class)
    expect(rule.tag).to eql('patent-use')
    expect(rule.description).to include('does NOT grant')
  end

  it 'loads all rules' do
    expect(described_class.all.count).to eql(16)
    rule = described_class.all.first
    expect(rule).to be_a(described_class)
    expect(rule.tag).to eql('commercial-use')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
licensee-8.8.5 spec/licensee/rule_spec.rb