require 'spec_helper'

describe Neighborly::Admin::AdminPolicy do
  subject { described_class }

  permissions :access? do
    it 'should deny access if user is nil' do
      should_not permit(nil, Neighborly::Admin)
    end

    it 'should deny access if user is not admin' do
      should_not permit(User.new, Neighborly::Admin)
    end

    it 'should permit access if user is admin' do
      user = User.new
      user.admin = true
      should permit(user, Neighborly::Admin)
    end
  end
end


require 'spec_helper'

describe Neighborly::Admin::AdminPolicy do
  subject { described_class }

  permissions :access? do
    it 'denies access if user is nil' do
      expect(subject).not_to permit(nil, Neighborly::Admin)
    end

    it 'denies access if user is not admin' do
      expect(subject).not_to permit(User.new, Neighborly::Admin)
    end

    it 'permits access if user is admin' do
      user = User.new
      user.admin = true
      expect(subject).to permit(user, Neighborly::Admin)
    end
  end
end


Refactor admin policy to use expect
Refactor admin policy to use expect
