Sha256: 14f056668b302eaf368f830216096d1dba70eb27b1481cc0c0de67e743813654
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
require_relative '../../spec_helper' describe 'DataMapper::Validations::Rule::Generic', '#optional?' do def validator(opts = {}) DataMapper::Validations::Rule::Length.new(:name, opts) end describe 'allowing blank' do subject do validator( :allow_blank => true ) end it { expect(subject.optional?("" )).to be } it { expect(subject.optional?(nil)).to be } end describe 'allowing nil' do subject do validator( :allow_nil => true ) end it { expect(subject.optional?("" )).not_to be } it { expect(subject.optional?(nil)).to be } end describe 'allowing blank, but now allowing nil' do subject do validator( :allow_blank => true, :allow_nil => false ) end it { expect(subject.optional?("" )).to be } it { expect(subject.optional?(nil)).not_to be } end describe 'allowing nil, but now allowing blank' do subject do validator( :allow_blank => false, :allow_nil => true ) end it { expect(subject.optional?("" )).not_to be } it { expect(subject.optional?(nil)).to be } end end
Version data entries
3 entries across 3 versions & 1 rubygems