public
Rubygem
Description: Extras for DataMapper, including bridges to DataObjects::Migrations and Merb::DataMapper
Homepage: http://datamapper.org
Clone URL: git://github.com/sam/dm-more.git
Search Repo:
Continued work to separate out spec files.

* Moved begin and rescue statements back into each spec.
myabc (author)
Thu May 08 07:07:12 -0700 2008
commit  f331f4c3fc6c52f69790feecfee0bb804a66296c
tree    5fb83dae55257e19319abeb649316564a5d8e835
parent  d030592d948d24d86511bc03af0026d7ebebce64
...
1
2
3
4
5
6
7
8
9
 
 
 
 
 
 
 
 
 
 
 
 
10
11
12
 
 
13
14
15
16
17
18
 
 
 
 
 
 
19
20
21
22
23
24
 
 
 
25
26
27
28
 
 
 
29
30
31
32
33
 
 
 
 
34
 
 
 
 
 
 
 
 
35
...
1
2
3
 
 
 
 
 
 
4
5
6
7
8
9
10
11
12
13
14
15
16
 
 
17
18
19
 
 
 
 
 
20
21
22
23
24
25
26
 
27
 
 
 
28
29
30
31
 
 
 
32
33
34
35
 
 
 
 
36
37
38
39
40
41
42
43
44
45
46
47
48
49
0
@@ -1,36 +1,50 @@
0
 require 'pathname'
0
 require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
0
 
0
-describe DataMapper::Validate::AbsentFieldValidator do
0
- before(:all) do
0
- class Kayak
0
- include DataMapper::Resource
0
- include DataMapper::Validate
0
- property :salesman, String, :auto_validation => false
0
+begin
0
+ gem 'do_sqlite3', '=0.9.0'
0
+ require 'do_sqlite3'
0
+
0
+ DataMapper.setup(:sqlite3, "sqlite3://#{DB_PATH}")
0
+
0
+ describe DataMapper::Validate::AbsentFieldValidator do
0
+ before(:all) do
0
+ class Kayak
0
+ include DataMapper::Resource
0
+ include DataMapper::Validate
0
+ property :salesman, String, :auto_validation => false
0
             
0
- validates_absence_of :salesman, :when => :sold
0
- end
0
+ validates_absence_of :salesman, :when => :sold
0
+ end
0
     
0
- class Pirogue
0
- include DataMapper::Resource
0
- include DataMapper::Validate
0
- property :salesman, String, :default => 'Layfayette'
0
- validates_absence_of :salesman, :when => :sold
0
+ class Pirogue
0
+ include DataMapper::Resource
0
+ include DataMapper::Validate
0
+ property :salesman, String, :default => 'Layfayette'
0
+ validates_absence_of :salesman, :when => :sold
0
+ end
0
     end
0
- end
0
 
0
- it "should validate the absense of a value on an instance of a resource" do
0
- kayak = Kayak.new
0
- kayak.valid_for_sold?.should == true
0
+ it "should validate the absense of a value on an instance of a resource" do
0
+ kayak = Kayak.new
0
+ kayak.valid_for_sold?.should == true
0
     
0
- kayak.salesman = 'Joe'
0
- kayak.valid_for_sold?.should_not == true
0
- end
0
+ kayak.salesman = 'Joe'
0
+ kayak.valid_for_sold?.should_not == true
0
+ end
0
   
0
- it "should validate the absense of a value and ensure defaults" do
0
- pirogue = Pirogue.new
0
- pirogue.should_not be_valid_for_sold
0
- end
0
+ it "should validate the absense of a value and ensure defaults" do
0
+ pirogue = Pirogue.new
0
+ pirogue.should_not be_valid_for_sold
0
+ end
0
   
0
+ end
0
+
0
+rescue LoadError => e
0
+ describe 'do_sqlite3' do
0
+ it 'should be required' do
0
+ fail "validation specs not run! Could not load do_sqlite3: #{e}"
0
+ end
0
+ end
0
 end
...
1
2
3
4
5
6
7
8
9
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
 
 
 
 
 
 
37
38
 
 
 
 
39
40
41
42
43
44
45
46
47
48
49
 
 
 
 
 
 
 
50
51
 
 
 
 
 
 
 
 
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
 
 
 
 
 
 
67
68
 
 
 
 
 
69
70
71
72
73
 
 
 
 
 
 
74
75
76
...
1
2
3
 
 
 
 
 
 
 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
39
40
41
42
43
44
45
 
46
47
48
49
50
 
 
 
 
 
 
 
 
 
 
51
52
53
54
55
56
57
58
 
59
60
61
62
63
64
65
66
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
69
70
71
72
73
74
75
 
76
77
78
79
80
81
 
 
 
 
82
83
84
85
86
87
88
89
90
0
@@ -1,76 +1,90 @@
0
 require 'pathname'
0
 require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
0
 
0
-describe DataMapper::Validate::AcceptanceValidator do
0
- describe "with standard options" do
0
- before :all do
0
- class SkimBat
0
- include DataMapper::Validate
0
- validates_acceptance_of :sailyness
0
- attr_accessor :sailyness
0
+begin
0
+ gem 'do_sqlite3', '=0.9.0'
0
+ require 'do_sqlite3'
0
+
0
+ DataMapper.setup(:sqlite3, "sqlite3://#{DB_PATH}")
0
+
0
+ describe DataMapper::Validate::AcceptanceValidator do
0
+ describe "with standard options" do
0
+ before :all do
0
+ class SkimBat
0
+ include DataMapper::Validate
0
+ validates_acceptance_of :sailyness
0
+ attr_accessor :sailyness
0
+ end
0
+ @s = SkimBat.new
0
       end
0
- @s = SkimBat.new
0
+ it "should validate if a resource instance has accepted" do
0
+ @s.sailyness = "1"
0
+ @s.valid?.should == true
0
+ end
0
+ it "should not validate if a resource instance has not accepted" do
0
+ @s.sailyness = "0"
0
+ @s.valid?.should == false
0
+ end
0
+ it "should allow nil acceptance" do
0
+ @s.sailyness = nil
0
+ @s.valid?.should == true
0
+ end
0
+ it "should add the default message when invalid" do
0
+ @s.sailyness = "0"
0
+ @s.valid?.should == false
0
+ @s.errors.full_messages.join(" ").should =~ /#{DataMapper::Validate::AcceptanceValidator.default_message_for_field("sailyness")}/
0
+ end
0
     end
0
- it "should validate if a resource instance has accepted" do
0
- @s.sailyness = "1"
0
- @s.valid?.should == true
0
- end
0
- it "should not validate if a resource instance has not accepted" do
0
- @s.sailyness = "0"
0
- @s.valid?.should == false
0
- end
0
- it "should allow nil acceptance" do
0
- @s.sailyness = nil
0
- @s.valid?.should == true
0
- end
0
- it "should add the default message when invalid" do
0
- @s.sailyness = "0"
0
- @s.valid?.should == false
0
- @s.errors.full_messages.join(" ").should =~ /#{DataMapper::Validate::AcceptanceValidator.default_message_for_field("sailyness")}/
0
- end
0
- end
0
- describe "with :allow_nil => false" do
0
- before :all do
0
- SkimBat.class_eval do
0
- validators.clear!
0
- validates_acceptance_of :sailyness, :allow_nil => false
0
+ describe "with :allow_nil => false" do
0
+ before :all do
0
+ SkimBat.class_eval do
0
+ validators.clear!
0
+ validates_acceptance_of :sailyness, :allow_nil => false
0
+ end
0
+ @s = SkimBat.new
0
       end
0
- @s = SkimBat.new
0
+ it "should not allow nil acceptance" do
0
+ @s.sailyness = nil
0
+ @s.valid?.should == false
0
+ end
0
     end
0
- it "should not allow nil acceptance" do
0
- @s.sailyness = nil
0
- @s.valid?.should == false
0
- end
0
- end
0
- describe "with custom :accept" do
0
- before :all do
0
- SkimBat.class_eval do
0
- validators.clear!
0
- validates_acceptance_of :sailyness, :accept => "true"
0
+ describe "with custom :accept" do
0
+ before :all do
0
+ SkimBat.class_eval do
0
+ validators.clear!
0
+ validates_acceptance_of :sailyness, :accept => "true"
0
+ end
0
+ @s = SkimBat.new
0
       end
0
- @s = SkimBat.new
0
+ it "should validate if a resource instance has accepted" do
0
+ @s.sailyness = "true"
0
+ @s.valid?.should == true
0
+ end
0
+ it "should not validate if a resource instance has not accepted" do
0
+ @s.sailyness = "false"
0
+ @s.valid?.should == false
0
+ end
0
     end
0
- it "should validate if a resource instance has accepted" do
0
- @s.sailyness = "true"
0
- @s.valid?.should == true
0
- end
0
- it "should not validate if a resource instance has not accepted" do
0
- @s.sailyness = "false"
0
- @s.valid?.should == false
0
- end
0
- end
0
- describe "with custom message" do
0
- before :all do
0
- SkimBat.class_eval do
0
- validators.clear!
0
- validates_acceptance_of :sailyness, :message => "hehu!"
0
+ describe "with custom message" do
0
+ before :all do
0
+ SkimBat.class_eval do
0
+ validators.clear!
0
+ validates_acceptance_of :sailyness, :message => "hehu!"
0
+ end
0
+ @s = SkimBat.new
0
       end
0
- @s = SkimBat.new
0
+ it "should append the custom message when invalid" do
0
+ @s.sailyness = "0"
0
+ @s.valid?.should == false
0
+ @s.errors.full_messages.join(" ").should =~ /hehu!/
0
+ end
0
     end
0
- it "should append the custom message when invalid" do
0
- @s.sailyness = "0"
0
- @s.valid?.should == false
0
- @s.errors.full_messages.join(" ").should =~ /hehu!/
0
+ end
0
+
0
+rescue LoadError => e
0
+ describe 'do_sqlite3' do
0
+ it 'should be required' do
0
+ fail "validation specs not run! Could not load do_sqlite3: #{e}"
0
     end
0
   end
0
 end
...
1
2
3
 
 
 
 
 
 
4
5
6
...
104
105
106
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
...
110
111
112
113
114
115
116
117
118
119
120
0
@@ -1,6 +1,12 @@
0
 require 'pathname'
0
 require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
0
 
0
+begin
0
+ gem 'do_sqlite3', '=0.9.0'
0
+ require 'do_sqlite3'
0
+
0
+ DataMapper.setup(:sqlite3, "sqlite3://#{DB_PATH}")
0
+
0
   describe "Automatic Validation from Property Definition" do
0
     before(:all) do
0
       class SailBoat
0
@@ -104,4 +110,12 @@
0
     end
0
         
0
   end
0
+
0
+rescue LoadError => e
0
+ describe 'do_sqlite3' do
0
+ it 'should be required' do
0
+ fail "validation specs not run! Could not load do_sqlite3: #{e}"
0
+ end
0
+ end
0
+end
...
1
2
3
4
5
6
7
8
9
10
 
 
 
 
 
 
 
 
 
 
 
 
 
11
12
13
14
 
 
 
15
16
17
18
 
 
 
19
20
21
22
 
 
 
23
24
 
 
25
26
27
28
29
30
31
32
33
 
 
 
 
 
 
34
35
36
37
 
 
 
38
39
40
41
42
43
44
 
 
 
 
 
 
45
46
47
48
49
50
51
52
53
 
 
54
55
56
57
58
59
60
61
62
63
 
 
 
 
64
65
66
67
68
 
69
70
71
72
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
 
75
76
 
 
 
 
 
 
77
...
1
2
3
 
 
 
 
 
 
 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
 
 
18
19
20
21
 
 
 
22
23
24
25
 
 
 
26
27
28
29
 
30
31
32
 
33
 
 
 
 
 
 
34
35
36
37
38
39
40
 
 
 
41
42
43
44
 
 
 
 
 
 
45
46
47
48
49
50
51
 
 
 
 
 
 
 
 
52
53
54
 
 
55
 
 
 
 
 
 
56
57
58
59
60
 
 
 
 
61
62
 
 
 
 
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
0
@@ -1,78 +1,92 @@
0
 require 'pathname'
0
 require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
0
 
0
-describe DataMapper::Validate::ConfirmationValidator do
0
- before(:all) do
0
- class Canoe
0
- include DataMapper::Validate
0
- def name=(value)
0
- @name = value
0
- end
0
+begin
0
+ gem 'do_sqlite3', '=0.9.0'
0
+ require 'do_sqlite3'
0
+
0
+ DataMapper.setup(:sqlite3, "sqlite3://#{DB_PATH}")
0
+
0
+ describe DataMapper::Validate::ConfirmationValidator do
0
+ before(:all) do
0
+ class Canoe
0
+ include DataMapper::Validate
0
+ def name=(value)
0
+ @name = value
0
+ end
0
       
0
- def name
0
- @name ||= nil
0
- end
0
+ def name
0
+ @name ||= nil
0
+ end
0
       
0
- def name_confirmation=(value)
0
- @name_confirmation = value
0
- end
0
+ def name_confirmation=(value)
0
+ @name_confirmation = value
0
+ end
0
       
0
- def name_confirmation
0
- @name_confirmation ||= nil
0
- end
0
+ def name_confirmation
0
+ @name_confirmation ||= nil
0
+ end
0
       
0
- validates_confirmation_of :name
0
+ validates_confirmation_of :name
0
+ end
0
     end
0
- end
0
   
0
- it "should validate the confirmation of a value on an instance of a resource" do
0
- canoe = Canoe.new
0
- canoe.name = 'White Water'
0
- canoe.name_confirmation = 'Not confirmed'
0
- canoe.valid?.should_not == true
0
- canoe.errors.full_messages.first.should == 'Name does not match the confirmation'
0
+ it "should validate the confirmation of a value on an instance of a resource" do
0
+ canoe = Canoe.new
0
+ canoe.name = 'White Water'
0
+ canoe.name_confirmation = 'Not confirmed'
0
+ canoe.valid?.should_not == true
0
+ canoe.errors.full_messages.first.should == 'Name does not match the confirmation'
0
     
0
- canoe.name_confirmation = 'White Water'
0
- canoe.valid?.should == true
0
- end
0
+ canoe.name_confirmation = 'White Water'
0
+ canoe.valid?.should == true
0
+ end
0
   
0
- it "should default the name of the confirmation field to <field>_confirmation if one is not specified" do
0
- canoe = Canoe.new
0
- canoe.name = 'White Water'
0
- canoe.name_confirmation = 'White Water'
0
- canoe.valid?.should == true
0
- end
0
+ it "should default the name of the confirmation field to <field>_confirmation if one is not specified" do
0
+ canoe = Canoe.new
0
+ canoe.name = 'White Water'
0
+ canoe.name_confirmation = 'White Water'
0
+ canoe.valid?.should == true
0
+ end
0
   
0
- it "should default to allowing nil values on the fields if not specified to" do
0
- Canoe.new().valid?().should == true
0
- end
0
-
0
- it "should not pass validation with a nil value when specified to" do
0
- class Canoe
0
- validators.clear!
0
- validates_confirmation_of :name, :allow_nil => false
0
+ it "should default to allowing nil values on the fields if not specified to" do
0
+ Canoe.new().valid?().should == true
0
     end
0
- Canoe.new().valid?().should_not == true
0
- end
0
   
0
- it "should allow the name of the confirmation field to be set" do
0
- class Canoe
0
- validators.clear!
0
- validates_confirmation_of :name, :confirm => :name_check
0
- def name_check=(value)
0
- @name_check = value
0
+ it "should not pass validation with a nil value when specified to" do
0
+ class Canoe
0
+ validators.clear!
0
+ validates_confirmation_of :name, :allow_nil => false
0
       end
0
-
0
- def name_check
0
- @name_confirmation ||= nil
0
- end
0
+ Canoe.new().valid?().should_not == true
0
     end
0
- canoe = Canoe.new
0
- canoe.name = 'Float'
0
- canoe.name_check = 'Float'
0
- canoe.valid?.should == true
0
+
0
+ it "should allow the name of the confirmation field to be set" do
0
+ class Canoe
0
+ validators.clear!
0
+ validates_confirmation_of :name, :confirm => :name_check
0
+ def name_check=(value)
0
+ @name_check = value
0
+ end
0
+
0
+ def name_check
0
+ @name_confirmation ||= nil
0
+ end
0
+ end
0
+ canoe = Canoe.new
0
+ canoe.name = 'Float'
0
+ canoe.name_check = 'Float'
0
+ canoe.valid?.should == true
0
     
0
+ end
0
+
0
   end
0
   
0
+rescue LoadError => e
0
+ describe 'do_sqlite3' do
0
+ it 'should be required' do
0
+ fail "validation specs not run! Could not load do_sqlite3: #{e}"
0
+ end
0
+ end
0
 end
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
0
@@ -1,3 +1,19 @@
0
 require 'pathname'
0
 require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
0
+
0
+begin
0
+ gem 'do_sqlite3', '=0.9.0'
0
+ require 'do_sqlite3'
0
+
0
+ DataMapper.setup(:sqlite3, "sqlite3://#{DB_PATH}")
0
+
0
+ # do something
0
+
0
+rescue LoadError => e
0
+ describe 'do_sqlite3' do
0
+ it 'should be required' do
0
+ fail "validation specs not run! Could not load do_sqlite3: #{e}"
0
+ end
0
+ end
0
+end
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
0
@@ -1,3 +1,19 @@
0
 require 'pathname'
0
 require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
0
+
0
+begin
0
+ gem 'do_sqlite3', '=0.9.0'
0
+ require 'do_sqlite3'
0
+
0
+ DataMapper.setup(:sqlite3, "sqlite3://#{DB_PATH}")
0
+
0
+ # do something
0
+
0
+rescue LoadError => e
0
+ describe 'do_sqlite3' do
0
+ it 'should be required' do
0
+ fail "validation specs not run! Could not load do_sqlite3: #{e}"
0
+ end
0
+ end
0
+end
...
1
2
3
 
 
 
 
 
 
4
5
6
...
76
77
78
79
80
81
 
 
 
 
 
 
 
82
83
84
...
1
2
3
4
5
6
7
8
9
10
11
12
...
82
83
84
 
 
 
85
86
87
88
89
90
91
92
93
94
0
@@ -1,6 +1,12 @@
0
 require 'pathname'
0
 require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
0
 
0
+begin
0
+ gem 'do_sqlite3', '=0.9.0'
0
+ require 'do_sqlite3'
0
+
0
+ DataMapper.setup(:sqlite3, "sqlite3://#{DB_PATH}")
0
+
0
   describe DataMapper::Validate::FormatValidator do
0
     before(:all) do
0
       class BillOfLading
0
@@ -76,9 +82,13 @@
0
     it 'should have pre-defined formats'
0
   end
0
 
0
-
0
-
0
-
0
+rescue LoadError => e
0
+ describe 'do_sqlite3' do
0
+ it 'should be required' do
0
+ fail "validation specs not run! Could not load do_sqlite3: #{e}"
0
+ end
0
+ end
0
+end
0
 
0
 =begin
0
 addresses = [
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
0
@@ -1,3 +1,19 @@
0
 require 'pathname'
0
 require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
0
+
0
+begin
0
+ gem 'do_sqlite3', '=0.9.0'
0
+ require 'do_sqlite3'
0
+
0
+ DataMapper.setup(:sqlite3, "sqlite3://#{DB_PATH}")
0
+
0
+ # do something
0
+
0
+rescue LoadError => e
0
+ describe 'do_sqlite3' do
0
+ it 'should be required' do
0
+ fail "validation specs not run! Could not load do_sqlite3: #{e}"
0
+ end
0
+ end
0
+end
...
1
2
3
4
5
6
7
8
9
10
 
 
 
 
 
 
 
 
 
 
 
 
 
11
12
13
14
15
16
 
 
 
 
 
 
17
18
19
20
21
22
 
 
 
 
 
 
 
 
23
24
25
26
27
28
29
30
31
32
33
 
 
 
 
 
 
 
 
 
34
35
36
37
38
39
40
41
42
43
44
 
 
 
 
 
 
 
 
 
45
46
47
48
49
50
51
52
53
54
55
 
 
 
 
 
 
 
 
 
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
 
 
 
 
 
 
 
 
72
73
74
75
 
 
 
76
77
78
79
80
81
82
83
84
 
 
85
86
87
88
89
90
91
92
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
95
...
1
2
3
 
 
 
 
 
 
 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
 
 
 
 
18
19
20
21
22
23
24
 
25
 
 
 
26
27
28
29
30
31
32
33
34
 
 
 
 
 
35
 
 
 
 
36
37
38
39
40
41
42
43
44
45
 
 
 
 
 
46
 
 
 
 
47
48
49
50
51
52
53
54
55
56
 
 
 
 
 
57
 
 
 
 
58
59
60
61
62
63
64
65
66
67
 
 
 
 
 
68
 
 
 
 
 
 
 
 
 
69
70
71
72
73
74
75
76
77
78
 
 
 
79
80
81
82
 
 
 
 
 
 
 
 
83
84
85
 
 
 
 
86
 
 
 
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
0
@@ -1,96 +1,110 @@
0
 require 'pathname'
0
 require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
0
 
0
-describe DataMapper::Validate::LengthValidator do
0
- before(:all) do
0
- class MotorLaunch
0
- include DataMapper::Resource
0
- include DataMapper::Validate
0
- property :name, String, :auto_validation => false
0
- end
0
+begin
0
+ gem 'do_sqlite3', '=0.9.0'
0
+ require 'do_sqlite3'
0
+
0
+ DataMapper.setup(:sqlite3, "sqlite3://#{DB_PATH}")
0
+
0
+ describe DataMapper::Validate::LengthValidator do
0
+ before(:all) do
0
+ class MotorLaunch
0
+ include DataMapper::Resource
0
+ include DataMapper::Validate
0
+ property :name, String, :auto_validation => false
0
+ end
0
     
0
- class BoatDock
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
+ class BoatDock
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
+ end
0
     end
0
- end
0
 
0
- it "should be able to set a minimum length of a string field" do
0
- class MotorLaunch
0
- validates_length_of :name, :min => 3
0
+ it "should be able to set a minimum length of a string field" do
0
+ class MotorLaunch
0
+ validates_length_of :name, :min => 3
0
+ end
0
+ launch = MotorLaunch.new
0
+ launch.name = 'Ab'
0
+ launch.valid?.should == false
0
+ launch.errors.full_messages.first.should == 'Name must be more than 3 characters long'
0
     end
0
- launch = MotorLaunch.new
0
- launch.name = 'Ab'
0
- launch.valid?.should == false
0
- launch.errors.full_messages.first.should == 'Name must be more than 3 characters long'
0
- end
0
   
0
- it "should be able to alias :minimum for :min " do
0
- class MotorLaunch
0
- validators.clear!
0
- validates_length_of :name, :minimum => 3
0
+ it "should be able to alias :minimum for :min " do
0
+ class MotorLaunch
0
+ validators.clear!
0
+ validates_length_of :name, :minimum => 3
0
+ end
0
+ launch = MotorLaunch.new
0
+ launch.name = 'Ab'
0
+ launch.valid?.should == false
0
+ launch.errors.full_messages.first.should == 'Name must be more than 3 characters long'
0
     end
0
- launch = MotorLaunch.new
0
- launch.name = 'Ab'
0
- launch.valid?.should == false
0
- launch.errors.full_messages.first.should == 'Name must be more than 3 characters long'
0
- end
0
   
0
- it "should be able to set a maximum length of a string field" do
0
- class MotorLaunch
0
- validators.clear!
0
- validates_length_of :name, :max => 5
0
+ it "should be able to set a maximum length of a string field" do
0
+ class MotorLaunch
0
+ validators.clear!
0
+ validates_length_of :name, :max => 5
0
+ end
0
+ launch = MotorLaunch.new
0
+ launch.name = 'Lip­smackin­thirst­quenchin­acetastin­motivatin­good­buzzin­cool­talkin­high­walkin­fast­livin­ever­givin­cool­fizzin'
0
+ launch.valid?.should == false
0
+ launch.errors.full_messages.first.should == 'Name must be less than 5 characters long'
0
     end
0
- launch = MotorLaunch.new
0
- launch.name = 'Lip­smackin­thirst­quenchin­acetastin­motivatin­good­buzzin­cool­talkin­high­walkin­fast­livin­ever­givin­cool­fizzin'
0
- launch.valid?.should == false
0
- launch.errors.full_messages.first.should == 'Name must be less than 5 characters long'
0
- end
0
   
0
- it "should be able to alias :maximum for :max" do
0
- class MotorLaunch
0
- validators.clear!
0
- validates_length_of :name, :maximum => 5
0
+ it "should be able to alias :maximum for :max" do
0
+ class MotorLaunch
0
+ validators.clear!
0
+ validates_length_of :name, :maximum => 5
0
+ end
0
+ launch = MotorLaunch.new
0
+ launch.name = 'Lip­smackin­thirst­quenchin­acetastin­motivatin­good­buzzin­cool­talkin­high­walkin­fast­livin­ever­givin­cool­fizzin'
0
+ launch.valid?.should == false
0
+ launch.errors.full_messages.first.should == 'Name must be less than 5 characters long'
0
     end
0
- launch = MotorLaunch.new
0
- launch.name = 'Lip­smackin­thirst­quenchin­acetastin­motivatin­good­buzzin­cool­talkin­high­walkin­fast­livin­ever­givin­cool­fizzin'
0
- launch.valid?.should == false
0
- launch.errors.full_messages.first.should == 'Name must be less than 5 characters long'
0
- end
0
   
0
- it "should be able to specify a length range of a string field" do
0
- class MotorLaunch
0
- validators.clear!
0
- validates_length_of :name, :in => (3..5)
0
- end
0
- launch = MotorLaunch.new
0
- launch.name = 'Lip­smackin­thirst­quenchin­acetastin­motivatin­good­buzzin­cool­talkin­high­walkin­fast­livin­ever­givin­cool­fizzin'
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
+ class MotorLaunch
0
+ validators.clear!
0
+ validates_length_of :name, :in => (3..5)
0
+ end
0
+ launch = MotorLaunch.new
0
+ launch.name = 'Lip­smackin­thirst­quenchin­acetastin­motivatin­good­buzzin­cool­talkin­high­walkin­fast­livin­ever­givin­cool­fizzin'
0
+ launch.valid?.should == false
0
+ launch.errors.full_messages.first.should == 'Name must be between 3 and 5 characters long'
0
     
0
- launch.name = 'A'
0
- launch.valid?.should == false
0
- launch.errors.full_messages.first.should == 'Name must be between 3 and 5 characters long'
0
+ launch.name = 'A'
0
+ launch.valid?.should == false
0
+ launch.errors.full_messages.first.should == 'Name must be between 3 and 5 characters long'
0
 
0
- launch.name = 'Ride'
0
- launch.valid?.should == true
0
- end
0
-
0
- it "should be able to alias :within for :in" do
0
- class MotorLaunch
0
- validators.clear!
0
- validates_length_of :name, :within => (3..5)
0
+ launch.name = 'Ride'
0
+ launch.valid?.should == true
0
     end
0
- launch = MotorLaunch.new
0
- launch.name = 'Ride'
0
- launch.valid?.should == true
0
- end
0
   
0
- it "should pass if a default fufills the requirements" do
0
- doc = BoatDock.new
0
- doc.should be_valid
0
+ it "should be able to alias :within for :in" do
0
+ class MotorLaunch
0
+ validators.clear!
0
+ validates_length_of :name, :within => (3..5)
0
+ end
0
+ launch = MotorLaunch.new
0
+ launch.name = 'Ride'
0
+ launch.valid?.should == true
0
+ end
0
+
0
+ it "should pass if a default fufills the requirements" do
0
+ doc = BoatDock.new
0
+ doc.should be_valid
0
+ end
0
+ end
0
+
0
+rescue LoadError => e
0
+ describe 'do_sqlite3' do
0
+ it 'should be required' do
0
+ fail "validation specs not run! Could not load do_sqlite3: #{e}"
0
+ end
0
   end
0
 end