Sha256: 6cbea140cf48f78a7fa4b989babd28c0a0d3e68fe75019484954fa921df8e4e2

Contents?: true

Size: 735 Bytes

Versions: 2

Compression:

Stored size: 735 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe DirtySeed::Assigners::Assigner do
  describe 'uniqueness' do
    context 'when value should be unique' do
      it 'returns unique value or nil' do
        attribute = build_attribute(:integer)
        assigner = DirtySeed::Assigners::Type::Integer.new(attribute)
        range = ActiveModel::Validations::NumericalityValidator.new(attributes: :fake, in: 1..2)
        uniqueness = ActiveRecord::Validations::UniquenessValidator.new(attributes: :fake)
        allow(assigner).to receive(:validators).and_return([range, uniqueness])
        values = Array.new(4) { assigner.value }
        expect(values).to match_array([1, 2, nil, nil])
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dirty_seed-0.2.1 spec/lib/dirty_seed/assigners/assigner_spec.rb
dirty_seed-0.2.0 spec/lib/dirty_seed/assigners/assigner_spec.rb