spec/extensions/auto_validations_spec.rb in sequel-4.5.0 vs spec/extensions/auto_validations_spec.rb in sequel-4.6.0
- old
+ new
@@ -25,89 +25,89 @@
@m = @c.new
db.sqls
end
it "should have automatically created validations" do
- @m.valid?.should be_false
+ @m.valid?.should == false
@m.errors.should == {:d=>["is not present"], :name=>["is not present"]}
@m.name = ''
- @m.valid?.should be_false
+ @m.valid?.should == false
@m.errors.should == {:d=>["is not present"]}
@m.set(:d=>'/', :num=>'a', :name=>'1')
- @m.valid?.should be_false
+ @m.valid?.should == false
@m.errors.should == {:d=>["is not a valid date"], :num=>["is not a valid integer"]}
@m.set(:d=>Date.today, :num=>1)
- @m.valid?.should be_false
+ @m.valid?.should == false
@m.errors.should == {[:name, :num]=>["is already taken"]}
end
it "should handle databases that don't support index parsing" do
def (@m.db).supports_index_parsing?() false end
@m.model.send(:setup_auto_validations)
@m.set(:d=>Date.today, :num=>1, :name=>'1')
- @m.valid?.should be_true
+ @m.valid?.should == true
end
it "should support :not_null=>:presence option" do
@c.plugin :auto_validations, :not_null=>:presence
@m.set(:d=>Date.today, :num=>'')
- @m.valid?.should be_false
+ @m.valid?.should == false
@m.errors.should == {:name=>["is not present"]}
end
it "should automatically validate explicit nil values for columns with not nil defaults" do
@m.set(:d=>Date.today, :name=>1, :nnd=>nil)
@m.id = nil
- @m.valid?.should be_false
+ @m.valid?.should == false
@m.errors.should == {:id=>["is not present"], :nnd=>["is not present"]}
end
it "should allow skipping validations by type" do
@c = Class.new(@c)
@m = @c.new
@c.skip_auto_validations(:not_null)
- @m.valid?.should be_true
+ @m.valid?.should == true
@m.set(:d=>'/', :num=>'a', :name=>'1')
- @m.valid?.should be_false
+ @m.valid?.should == false
@m.errors.should == {:d=>["is not a valid date"], :num=>["is not a valid integer"]}
@c.skip_auto_validations(:types)
- @m.valid?.should be_false
+ @m.valid?.should == false
@m.errors.should == {[:name, :num]=>["is already taken"]}
@c.skip_auto_validations(:unique)
- @m.valid?.should be_true
+ @m.valid?.should == true
end
it "should allow skipping all auto validations" do
@c = Class.new(@c)
@m = @c.new
@c.skip_auto_validations(:all)
- @m.valid?.should be_true
+ @m.valid?.should == true
@m.set(:d=>'/', :num=>'a', :name=>'1')
- @m.valid?.should be_true
+ @m.valid?.should == true
end
it "should work correctly in subclasses" do
@c = Class.new(@c)
@m = @c.new
- @m.valid?.should be_false
+ @m.valid?.should == false
@m.errors.should == {:d=>["is not present"], :name=>["is not present"]}
@m.set(:d=>'/', :num=>'a', :name=>'1')
- @m.valid?.should be_false
+ @m.valid?.should == false
@m.errors.should == {:d=>["is not a valid date"], :num=>["is not a valid integer"]}
@m.set(:d=>Date.today, :num=>1)
- @m.valid?.should be_false
+ @m.valid?.should == false
@m.errors.should == {[:name, :num]=>["is already taken"]}
end
it "should work correctly when changing the dataset" do
@c.set_dataset(@c.db[:foo])
- @c.new.valid?.should be_true
+ @c.new.valid?.should == true
end
end