Sha256: 9b69d2a4625092485b28afaa89635c6c140235e76c0fc9e2d21ea96cfd52a7e4

Contents?: true

Size: 996 Bytes

Versions: 2

Compression:

Stored size: 996 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

2 entries across 2 versions & 1 rubygems

Version Path
attestor-1.0.0 spec/tests/validations/delegator_spec.rb
attestor-0.4.0 spec/tests/validations/delegator_spec.rb