Sha256: 977c6bcdd7f95b6de4b0cba8fbc92968c1e40c788a7b7dc2ded418321a8e034b

Contents?: true

Size: 991 Bytes

Versions: 1

Compression:

Stored size: 991 Bytes

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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arpa-0.3.0 spec/lib/arpa/additions/resource_spec.rb