Sha256: 69cf714df03f3c0f1b9ab9666088d49e16674627c364da5671390b8b9d79ad42

Contents?: true

Size: 882 Bytes

Versions: 4

Compression:

Stored size: 882 Bytes

Contents

# frozen_string_literal: true

require "rails_helper"

module Archangel
  RSpec.describe Field, type: :model do
    context "validations" do
      it { expect(subject).to validate_presence_of(:classification) }
      it { expect(subject).to validate_presence_of(:collection_id).on(:update) }
      it { expect(subject).to validate_presence_of(:label) }
      it { expect(subject).to validate_presence_of(:slug) }

      it { expect(subject).to allow_value(true).for(:required) }
      it { expect(subject).to allow_value(false).for(:required) }
      it { expect(subject).not_to allow_value(nil).for(:required) }

      it do
        expect(subject).to(
          validate_inclusion_of(:classification)
            .in_array(%w[string text boolean])
        )
      end
    end

    context "associations" do
      it { expect(subject).to belong_to(:collection) }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
archangel-0.0.5 spec/models/archangel/field_spec.rb
archangel-0.0.4 spec/models/archangel/field_spec.rb
archangel-0.0.3 spec/models/archangel/field_spec.rb
archangel-0.0.2 spec/models/archangel/field_spec.rb