0
@@ -412,6 +412,14 @@ begin
0
validates_presence_of :name, :when => :property_test
0
validates_presence_of :landscaper, :when => :association_test
0
+ include DataMapper::Resource
0
+ include DataMapper::Validate
0
+ property :id, Fixnum, :serial => true
0
+ property :brand, String, :auto_validation => false, :default => 'Scotts'
0
+ validates_presence_of :brand, :when => :property_test
0
it "should validate the presence of a property value on an instance of a resource" do
0
@@ -431,6 +439,10 @@ begin
0
# #puts "Gardens landscaper is #{garden.landscaper.child_key}"
0
+ it "should pass when a default is available" do
0
+ fert.should be_valid_for_property_test
0
@@ -444,6 +456,13 @@ begin
0
validates_absence_of :salesman, :when => :sold
0
+ include DataMapper::Resource
0
+ include DataMapper::Validate
0
+ property :salesman, String, :default => 'Layfayette'
0
+ validates_absence_of :salesman, :when => :sold
0
it "should validate the absense of a value on an instance of a resource" do
0
@@ -454,6 +473,11 @@ begin
0
kayak.valid_for_sold?.should_not == true
0
+ it "should validate the absense of a value and ensure defaults" do
0
+ pirogue.should_not be_valid_for_sold
0
#-------------------------------------------------------------------------------
0
@@ -556,7 +580,7 @@ begin
0
- it "should validate the conf
rimation of a value on an instance of a resource" do
0
+ it "should validate the conf
irmation of a value on an instance of a resource" do
0
canoe.name = 'White Water'
0
canoe.name_confirmation = 'Not confirmed'
0
@@ -567,7 +591,7 @@ begin
0
canoe.valid?.should == true
0
- it "should default the name of the confir
imation field to <field>_confirmation if one is not specified" do
0
+ it "should default the name of the confir
mation field to <field>_confirmation if one is not specified" do
0
canoe.name = 'White Water'
0
canoe.name_confirmation = 'White Water'
0
@@ -740,6 +764,13 @@ end
0
include DataMapper::Validate
0
property :name, String, :auto_validation => false
0
+ include DataMapper::Resource
0
+ include DataMapper::Validate
0
+ property :name, String, :auto_validation => false, :default => "I'm a long string"
0
+ validates_length_of :name, :min => 3
0
it 'should be able to set a minimum length of a string field' do
0
@@ -812,6 +843,11 @@ end
0
launch.valid?.should == true
0
+ it "should pass if a default fufills the requirements" do
0
#-------------------------------------------------------------------------------
0
@@ -890,6 +926,14 @@ end
0
validates_numericalnes_of :amount_1, :amount_2
0
+ include DataMapper::Resource
0
+ include DataMapper::Validate
0
+ property :amount_1, Float, :auto_validation => false, :default => 0.01
0
+ validates_numericalnes_of :amount_1
0
it "should validate a floating point value on the instance of a resource" do
0
@@ -923,6 +967,11 @@ end
0
+ it "should validate if a default fufills the requirements" do