Sha256: bcbe144bb52fe951548b4ad7d1fca6ff928e15b484b7044381b7d8c343bee529
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe DirtySeed::Assigners::Float do let(:attribute) { build_attribute(type: :float) } describe '#value' do context 'when there are no validators' do it 'returns a float' do 10.times { expect(described_class.new(attribute).value).to be_a Float } end end context 'when there is greater_than validator' do it 'returns a float greater than the requirement' do assigner = described_class.new(attribute) validator = ActiveModel::Validations::NumericalityValidator.new(attributes: :fake, greater_than: 1_000) allow(attribute).to receive(:validators).and_return([validator]) 10.times { expect(assigner.value).to be >= 1_000 } end end context 'when there is less_than validator' do it 'returns a float less than the requirement' do assigner = described_class.new(attribute) validator = ActiveModel::Validations::NumericalityValidator.new(attributes: :fake, less_than: -1_000) allow(attribute).to receive(:validators).and_return([validator]) 10.times { expect(assigner.value).to be < -1_000 } end end context 'when there is greater_and less_than validators' do it 'returns a float greater than and less than the requirements' do assigner = described_class.new(attribute) validator = ActiveModel::Validations::NumericalityValidator.new(attributes: :fake, greater_than: 0, less_than: 1) allow(attribute).to receive(:validators).and_return([validator]) 10.times { expect(assigner.value).to be_between(0, 1).exclusive } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dirty_seed-0.1.8 | spec/lib/dirty_seed/assigners/float_spec.rb |