Sha256: b0b2b16f74c982aa41f93099785c987b9355e17e04adf094df9f52e0fe4f35fa

Contents?: true

Size: 799 Bytes

Versions: 2

Compression:

Stored size: 799 Bytes

Contents

require 'spec_helper'
require 'kankri'

# A mock object for testing PrivilegeSubject
class MockPrivilegeSubject
  include Kankri::PrivilegeSubject

  def privilege_key
    :fake_key
  end
end

describe MockPrivilegeSubject do
  let(:privilege_set) { double(:privilege_set) }
  let(:operation) { double(:operation) }

  { fail_if_cannot: :require, can?: :has? }.each do |subject_meth, set_meth|
    describe "##{subject_meth}" do
      context 'when given a valid privilege set and operation' do
        it "calls ##{set_meth} on the privilege set with the handler target" do
          expect(privilege_set).to receive(set_meth).once.with(
            operation, subject.privilege_key
          )
          subject.send(subject_meth, operation, privilege_set)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kankri-0.1.2 spec/privilege_subject_spec.rb
kankri-0.1.1 spec/privilege_subject_spec.rb