Sha256: 96ab7c0901d440cfdc5630a8a7f11b80aedc15a1e47150beea22b5ce401f743e

Contents?: true

Size: 1002 Bytes

Versions: 4

Compression:

Stored size: 1002 Bytes

Contents

# encoding: utf-8

require "support/policies"

describe Attestor::Validations::Delegator do

  let(:validator) { Attestor::Validations::Validator }

  describe ".new" do

    subject { described_class.new "foo" }
    it { is_expected.to be_kind_of validator }

  end # describe .new

  describe "#validate!" do

    let(:object) { double foo: valid_policy }

    context "when initialized without a block" do

      subject { described_class.new "foo" }
      after   { subject.validate! object   }

      it "delegates validation to named method" do
        expect(object).to receive_message_chain(:foo, :validate!)
      end

    end # context

    context "when initialized with a block" do

      subject { described_class.new { foo } }
      after   { subject.validate! object }

      it "delegates validation to block" do
        expect(object).to receive_message_chain(:foo, :validate!)
      end

    end # context

  end # describe #validate!

end # describe Attestor::Validations::Delegator

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
attestor-2.2.1 spec/tests/validations/delegator_spec.rb
attestor-2.2.0 spec/tests/validations/delegator_spec.rb
attestor-2.1.0 spec/tests/validations/delegator_spec.rb
attestor-2.0.0 spec/tests/validations/delegator_spec.rb