Sha256: a55069d271a46aab652490cc9fee601f7de4c089895dc5c3fa512213d92396b7

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

# encoding: utf-8

describe Attestor::Validations::Context do

  let(:klass)   { double validate: nil, validates: nil }
  let(:options) { { except: :foo, only: :bar }         }
  let(:name)    { :baz                                 }
  let(:block)   { proc { :foo }                        }
  subject       { described_class.new klass, options   }

  describe "#klass" do

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

  end # describe #klass

  describe "#options" do

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

  end # describe #options

  describe "#validate" do

    it "is delegated to klass with name and options" do
      expect(klass).to receive(:validate).with(name, **options)
      subject.validate name
    end

    it "is delegated to klass with a block" do
      expect(klass).to receive(:validate) do |*, &b|
        expect(b).to eq block
      end
      subject.validate(&block)
    end

  end # describe #validate

  describe "#validates" do

    it "is delegated to klass with name and options" do
      expect(klass).to receive(:validates).with(name, **options)
      subject.validates name
    end

    it "is delegated to klass with a block" do
      expect(klass).to receive(:validates) do |*, &b|
        expect(b).to eq block
      end
      subject.validates(&block)
    end

  end # describe #validates

end # describe Attestor::Validations::Context

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
attestor-2.2.1 spec/tests/validations/context_spec.rb
attestor-2.2.0 spec/tests/validations/context_spec.rb