Sha256: deac7b82798a9026d3cc94599c6f9a08b7e7a60f8f3257e17ee18afd8401fae5

Contents?: true

Size: 605 Bytes

Versions: 2

Compression:

Stored size: 605 Bytes

Contents

require 'rails_helper'

module Theblog
  RSpec.describe Account, :type => :model do
    it { is_expected.to have_many(:accounts_roles) }
    it { is_expected.to have_many(:roles) }

    describe '#has_role?' do
      let(:account) { FactoryGirl.create :confirmed_account }
      let(:role) { 'admin' }

      subject { account.has_role?(role) }

      context 'role exists' do
        before { account.roles << Theblog::Role.find_by(name: role) }

        it { is_expected.to be_truthy }
      end

      context "role doesn't exist" do
        it { is_expected.to be_falsey }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
theblog-0.0.2.3 spec/models/theblog/account_spec.rb
theblog-0.0.2.2 spec/models/theblog/account_spec.rb