Sha256: 2bfea66911b11f49a1a4bb53d114d5d82db61a843c32a1ddfcfd39ba75461207

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'
require 'support/shared_examples_for_validators'

shared_examples "it validates the single cardinality of the attribute" do
  it_behaves_like "it validates the single cardinality of a scalar attribute"
  it_behaves_like "it validates the single cardinality of an enumerable attribute"
end

describe Hydra::Validations::SingleCardinalityValidator do
  before(:all) do
    class Validatable
      include ActiveModel::Validations
      include Hydra::Validations
      attr_accessor :field
    end
  end
  before(:each) { Validatable.clear_validators! }
  after(:all) { Object.send(:remove_const, :Validatable) }
  subject { Validatable.new }
  describe ".validates" do
    before { Validatable.validates :field, single_cardinality: true }
    it_behaves_like "it validates the single cardinality of the attribute" do
      let(:attribute) { :field }
    end
  end
  describe ".validates_single_cardinality_of" do
    before { Validatable.validates_single_cardinality_of :field }
    it_behaves_like "it validates the single cardinality of the attribute" do
      let(:attribute) { :field }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hydra-validations-0.3.2 spec/validators/single_cardinality_validator_spec.rb
hydra-validations-0.3.1 spec/validators/single_cardinality_validator_spec.rb
hydra-validations-0.3.0 spec/validators/single_cardinality_validator_spec.rb
hydra-validations-0.2.1 spec/validators/single_cardinality_validator_spec.rb
hydra-validations-0.2.0 spec/validators/single_cardinality_validator_spec.rb