Sha256: cad941b3437b1473666c030964c9fc4d0392cf1ddbb233ea5c022508ebba8a2a

Contents?: true

Size: 1.38 KB

Versions: 38

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe Hydra::AccessControls::Permission do

  describe "an initialized instance" do
    let(:permission) { described_class.new(type: 'person', name: 'bob', access: 'read') }

    it "should set predicates" do
      expect(permission.agent.first.rdf_subject).to eq ::RDF::URI.new('http://projecthydra.org/ns/auth/person#bob')
      expect(permission.mode.first.rdf_subject).to eq ACL.Read
    end

    describe "#to_hash" do
      subject { permission.to_hash }
      it { should eq(type: 'person', name: 'bob', access: 'read') }
    end

    describe "#agent_name" do
      subject { permission.agent_name }
      it { should eq 'bob' }
    end

    describe "#access" do
      subject { permission.access }
      it { should eq 'read' }
    end

    describe "#type" do
      subject { permission.type }
      it { should eq 'person' }
    end
  end

  describe "equality comparison" do
    let(:perm1) { described_class.new(type: 'person', name: 'bob', access: 'read') }
    let(:perm2) { described_class.new(type: 'person', name: 'bob', access: 'read') }
    let(:perm3) { described_class.new(type: 'person', name: 'jane', access: 'read') }

    it "should be equal if all values are equal" do
      expect(perm1).to eq perm2
    end

    it "should be unequal if some values are unequal" do
      expect(perm1).to_not eq perm3
      expect(perm2).to_not eq perm3
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
hydra-access-controls-9.4.0 spec/unit/permission_spec.rb
hydra-access-controls-9.3.0 spec/unit/permission_spec.rb
hydra-access-controls-9.2.2 spec/unit/permission_spec.rb
hydra-access-controls-9.2.1 spec/unit/permission_spec.rb
hydra-access-controls-9.2.0 spec/unit/permission_spec.rb
hydra-access-controls-9.2.0.rc1 spec/unit/permission_spec.rb
hydra-access-controls-9.1.4 spec/unit/permission_spec.rb
hydra-access-controls-9.1.3 spec/unit/permission_spec.rb
hydra-access-controls-9.1.2 spec/unit/permission_spec.rb
hydra-access-controls-9.1.1 spec/unit/permission_spec.rb
hydra-access-controls-9.1.0 spec/unit/permission_spec.rb
hydra-access-controls-9.0.1 spec/unit/permission_spec.rb
hydra-access-controls-9.0.0 spec/unit/permission_spec.rb
hydra-access-controls-9.0.0.rc3 spec/unit/permission_spec.rb
hydra-access-controls-9.0.0.rc2 spec/unit/permission_spec.rb
hydra-access-controls-9.0.0.rc1 spec/unit/permission_spec.rb
hydra-access-controls-9.0.0.beta2 spec/unit/permission_spec.rb
hydra-access-controls-9.0.0.beta1 spec/unit/permission_spec.rb