# encoding: utf-8

describe Policy::Follower::ViolationError do

  let(:errors)   { double :errors   }
  let(:follower) { double :follower }
  let(:policy)   { double :policy, errors: errors }
  subject        { described_class.new follower, policy }

  describe ".new" do

    it "creates the RuntimeError" do
      expect(subject).to be_kind_of ::RuntimeError
    end

  end # describe .new

  describe "#follower" do

    it "is initialized" do
      expect(subject.follower).to eq follower
    end

  end # describe #follower

  describe "#policy" do

    it "is initialized" do
      expect(subject.policy).to eq policy
    end

  end # describe #policy

  describe "#errors" do

    it "is initialized" do
      expect(subject.errors).to eq errors
    end

  end # describe #errors

  describe "#message" do

    it "returns a correct string" do
      expect(subject.message)
        .to eq "#{ follower.inspect } violates the policy #{ policy }"
    end

  end # describe #message

  describe "#inspect" do

    it "returns a correct string" do
      expect(subject.inspect)
        .to eq "#<#{ described_class.name }: #{ subject.message }>"
    end

  end # describe #inspect

end # describe Policy::Follower::NameError