0
require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
0
-describe DataMapper::Validate::LengthValidator do
0
- include DataMapper::Resource
0
- include DataMapper::Validate
0
- property :name, String, :auto_validation => false
0
+ gem 'do_sqlite3', '=0.9.0'
0
+ DataMapper.setup(:sqlite3, "sqlite3://#{DB_PATH}")
0
+ describe DataMapper::Validate::LengthValidator do
0
+ include DataMapper::Resource
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
+ 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
- validates_length_of :name, :min => 3
0
+ it "should be able to set a minimum length of a string field" do
0
+ validates_length_of :name, :min => 3
0
+ launch = MotorLaunch.new
0
+ launch.valid?.should == false
0
+ launch.errors.full_messages.first.should == 'Name must be more than 3 characters long'
0
- launch = MotorLaunch.new
0
- launch.valid?.should == false
0
- launch.errors.full_messages.first.should == 'Name must be more than 3 characters long'
0
- it "should be able to alias :minimum for :min " do
0
- validates_length_of :name, :minimum => 3
0
+ it "should be able to alias :minimum for :min " do
0
+ validates_length_of :name, :minimum => 3
0
+ launch = MotorLaunch.new
0
+ launch.valid?.should == false
0
+ launch.errors.full_messages.first.should == 'Name must be more than 3 characters long'
0
- launch = MotorLaunch.new
0
- launch.valid?.should == false
0
- launch.errors.full_messages.first.should == 'Name must be more than 3 characters long'
0
- it "should be able to set a maximum length of a string field" do
0
- validates_length_of :name, :max => 5
0
+ it "should be able to set a maximum length of a string field" do
0
+ validates_length_of :name, :max => 5
0
+ launch = MotorLaunch.new
0
+ launch.name = 'Lipsmackinthirstquenchinacetastinmotivatingoodbuzzincooltalkinhighwalkinfastlivinevergivincoolfizzin'
0
+ launch.valid?.should == false
0
+ launch.errors.full_messages.first.should == 'Name must be less than 5 characters long'
0
- launch = MotorLaunch.new
0
- launch.name = 'Lipsmackinthirstquenchinacetastinmotivatingoodbuzzincooltalkinhighwalkinfastlivinevergivincoolfizzin'
0
- launch.valid?.should == false
0
- launch.errors.full_messages.first.should == 'Name must be less than 5 characters long'
0
- it "should be able to alias :maximum for :max" do
0
- validates_length_of :name, :maximum => 5
0
+ it "should be able to alias :maximum for :max" do
0
+ validates_length_of :name, :maximum => 5
0
+ launch = MotorLaunch.new
0
+ launch.name = 'Lipsmackinthirstquenchinacetastinmotivatingoodbuzzincooltalkinhighwalkinfastlivinevergivincoolfizzin'
0
+ launch.valid?.should == false
0
+ launch.errors.full_messages.first.should == 'Name must be less than 5 characters long'
0
- launch = MotorLaunch.new
0
- launch.name = 'Lipsmackinthirstquenchinacetastinmotivatingoodbuzzincooltalkinhighwalkinfastlivinevergivincoolfizzin'
0
- launch.valid?.should == false
0
- launch.errors.full_messages.first.should == 'Name must be less than 5 characters long'
0
- it "should be able to specify a length range of a string field" do
0
- validates_length_of :name, :in => (3..5)
0
- launch = MotorLaunch.new
0
- launch.name = 'Lipsmackinthirstquenchinacetastinmotivatingoodbuzzincooltalkinhighwalkinfastlivinevergivincoolfizzin'
0
- launch.valid?.should == false
0
- launch.errors.full_messages.first.should == 'Name must be between 3 and 5 characters long'
0
+ it "should be able to specify a length range of a string field" do
0
+ validates_length_of :name, :in => (3..5)
0
+ launch = MotorLaunch.new
0
+ launch.name = 'Lipsmackinthirstquenchinacetastinmotivatingoodbuzzincooltalkinhighwalkinfastlivinevergivincoolfizzin'
0
+ launch.valid?.should == false
0
+ launch.errors.full_messages.first.should == 'Name must be between 3 and 5 characters long'
0
- launch.valid?.should == false
0
- launch.errors.full_messages.first.should == 'Name must be between 3 and 5 characters long'
0
+ launch.valid?.should == false
0
+ launch.errors.full_messages.first.should == 'Name must be between 3 and 5 characters long'
0
- launch.valid?.should == true
0
- it "should be able to alias :within for :in" do
0
- validates_length_of :name, :within => (3..5)
0
+ launch.valid?.should == true
0
- launch = MotorLaunch.new
0
- launch.valid?.should == true
0
- it "should pass if a default fufills the requirements" do
0
+ it "should be able to alias :within for :in" do
0
+ validates_length_of :name, :within => (3..5)
0
+ launch = MotorLaunch.new
0
+ launch.valid?.should == true
0
+ it "should pass if a default fufills the requirements" do
0
+ describe 'do_sqlite3' do
0
+ it 'should be required' do
0
+ fail "validation specs not run! Could not load do_sqlite3: #{e}"