Sha256: c3e38462790cd03d76921db4f3504d39660d00f78473e4c3b0e4912956f180ed
Contents?: true
Size: 1.77 KB
Versions: 19
Compression:
Stored size: 1.77 KB
Contents
require 'spec_helper' describe Riveter::EmailValidator do subject { Riveter::EmailValidator } describe "#validate_each" do def record_for(value) record = double() allow(record).to receive(:read_attribute_for_validation) { value } record end def errors errors = double allow(errors).to receive(:add) errors end describe "with defaults" do it { validator = subject.new(:attributes => [:test]) record = record_for('not_an_email') expect(record).to receive(:errors).and_return(errors) validator.validate(record) } it { validator = subject.new(:attributes => [:test]) record = record_for('some@email.com') expect(record).to_not receive(:errors) validator.validate(record) } end describe "with allow_nil" do it { validator = subject.new(:attributes => [:test], :allow_nil => false) record = record_for(nil) expect(record).to receive(:errors).and_return(errors) validator.validate(record) } it { validator = subject.new(:attributes => [:test], :allow_nil => true) record = record_for(nil) expect(record).to_not receive(:errors) validator.validate(record) } end describe "with allow_blank" do it { validator = subject.new(:attributes => [:test], :allow_blank => false) record = record_for('') expect(record).to receive(:errors).and_return(errors) validator.validate(record) } it { validator = subject.new(:attributes => [:test], :allow_blank => true) record = record_for('') expect(record).to_not receive(:errors) validator.validate(record) } end end end
Version data entries
19 entries across 19 versions & 1 rubygems