Sha256: 27c934cafe79456abe35d6f7b90b5a62a312a62ce1412309d853ad7b573617c7
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
require 'spec_helper' describe NotEqualsValidator do # Undo validations after each test before { Test.reset_callbacks(:validate) } context "without an :allow_nil key given:" do before { Test.validates :finish, not_equals: { to: :start }} let!(:test) { Test.new } context "if the attributes' values differ" do before do test.start = 2.days.ago.to_date test.finish = 1.day.ago.to_date end it "validation passes" do test.should be_valid test.errors.should be_blank end end context "if the attributes' values are equal" do before { test.start = test.finish = 1.day.ago.to_date } it "validation fails" do test.should_not be_valid test.errors.should_not be_blank end end context "if both the attributes' values aren't set" do before do test.start = nil test.finish = nil end it "validation fails" do test.should_not be_valid test.errors.should_not be_blank end end end context "with an :allow_nil option set to true:" do before { Test.validates :finish, not_equals: { to: :start, allow_nil: true }} let!(:test) { Test.new } context "if both the attributes' values aren't set" do before do test.start = nil test.finish = nil end it "validation passes" do test.should be_valid test.errors.should be_blank end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_validators-1.1.1 | spec/validators/not_equals_validator_spec.rb |
active_validators-1.1.0 | spec/validators/not_equals_validator_spec.rb |