Sha256: 1c95a14b60d56df92b2dc8bc6a111c1bca530f10e78eeab5053ebc7d28027183

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

class ResourceImplementation
  def self.helper_method(args);end
  include Arpa::Additions::Resource
  def session;'';end
  def current_user;'';end
end

describe Arpa::Additions::Resource, type: :addition, fast: true do

  let(:resource_implementation) { ResourceImplementation.new }

  let(:verifier) { double }
  let(:resource) { double }
  let(:action)   { double }

  before do
    allow(Arpa::Services::Verifier).to receive(:new).and_return(verifier)
    setup
  end

  describe '#has_access?' do

    let(:setup) do
      allow(verifier).to receive(:has_access?)
      resource_implementation.has_access?(resource, action)
    end

    it 'should call :new from Arpa::Services::Verifier' do
      expect(Arpa::Services::Verifier).to have_received(:new).once
    end

    it 'verifier should call :has_access? with resource and action as parameter' do
      expect(verifier).to have_received(:has_access?).with(resource, action).once
    end
  end

   describe '#reset_permissions' do

     let(:setup) do
      allow(verifier).to receive(:reset_permissions)
      resource_implementation.reset_permissions
    end

    it 'should call :new from Arpa::Services::Verifier' do
      expect(Arpa::Services::Verifier).to have_received(:new).once
    end

    it 'verifier should call :reset_permissions once' do
      expect(verifier).to have_received(:reset_permissions).once
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
arpa-0.0.9 spec/lib/arpa/additions/resource_spec.rb
arpa-0.0.8 spec/lib/ar/additions/resource_spec.rb
arpa-0.0.7 spec/lib/ar/additions/resource_spec.rb
arpa-0.0.6 spec/lib/ar/additions/resource_spec.rb
arpa-0.0.5 spec/lib/ar/additions/resource_spec.rb