Sha256: fa8b6e9d8e46605fa083e1deee634c03c4cbdc5b8eee40e61bc8147eda553ae8

Contents?: true

Size: 1.17 KB

Versions: 10

Compression:

Stored size: 1.17 KB

Contents

# encoding: utf-8

describe Attestor::Policy::Negator do

  let(:composer)  { Attestor::Policy::Node }
  let(:not_class) { Attestor::Policy::Not  }
  let(:policy)    { double :policy }

  subject { described_class.new composer, policy }

  describe ".new" do

    it "creates immutable object" do
      expect(subject).to be_frozen
    end

  end

  describe "#policy" do

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

  end # describe #policy

  describe "#composer" do

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

  end # describe #composer

  describe "#not" do

    let(:another) { double :another }
    let(:result)  { subject.not(another) }

    it "creates a composer object" do
      expect(result).to be_kind_of composer
    end

    it "sends its policy to the composer" do
      expect(result.branches).to include policy
    end

    it "sends the negated arguments to the composer" do
      negation = double :negation
      expect(not_class).to receive(:new).with(another).and_return(negation)

      expect(result.branches).to include negation
    end

  end # describe #not

end # describe Policy::Base::Negator

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
attestor-2.2.1 spec/tests/policy/negator_spec.rb
attestor-2.2.0 spec/tests/policy/negator_spec.rb
attestor-2.1.0 spec/tests/policy/negator_spec.rb
attestor-2.0.0 spec/tests/policy/negator_spec.rb
attestor-1.0.0 spec/tests/policy/negator_spec.rb
attestor-0.4.0 spec/tests/policy/negator_spec.rb
attestor-0.3.0 spec/tests/policy/negator_spec.rb
attestor-0.2.0 spec/tests/policy/negator_spec.rb
attestor-0.1.0 spec/tests/policy/negator_spec.rb
attestor-0.0.1 spec/tests/policy/negator_spec.rb