public
Description: Helpful rspec matchers for testing validations and associations.
Homepage: http://am.freelancing-gods.com
Clone URL: git://github.com/freelancing-god/active-matchers.git
Whoops, lets fix up that spacing and make sure the gem builds correctly.
chrislloyd (author)
Tue Jul 01 22:33:09 -0700 2008
commit  f496bb7a2e8df5694402cd1db10a3e5f767fedbc
tree    e8243fe9cf8fabc4f56d1d79314f488dabf68b4d
parent  ff3614a9fdb74a7fc6a4029aaea57592c4cdbe9b
...
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
...
45
46
47
 
48
49
50
 
51
52
53
54
 
55
56
57
 
58
59
60
...
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
...
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
0
@@ -11,31 +11,40 @@ Make sure, in your spec_helper.rb file, you add an include as follows:
0
 h2. Usage
0
 
0
 Test @validates_presence_of :name@
0
+
0
   Model.should need(:name).using(@valid_attributes)
0
 
0
 Test @validates_uniqueness_of :name@
0
+
0
   Model.should need(:name).to_be_unique.using(@valid_attributes)
0
 
0
 Test presence of at least one field being required
0
+
0
   Model.should need.one_of(:first_name, :last_name).using(@valid_attributes)
0
 
0
 Test @validates_length_of :name matches@ database field length
0
+
0
   Model.should limit_length_of(:name).using(@valid_attributes)
0
 
0
 Test @validates_length_of :name, :maximum => 255@
0
+
0
   Model.should limit_length_of(:name).to(255).using(@valid_attributes)
0
 
0
 Test @validates_length_of :name, :minimum => 3@@
0
+
0
   Model.should limit_length_of(:name).from(3).using(@valid_attributes)
0
 
0
 Test @validates_length_of :name, :within => 3..40@
0
+
0
   Model.should limit_length_of(:name).from(3).to(4).using(@valid_attributes)
0
 
0
 Test @validates_numericality_of :age@
0
+
0
   Model.should need_numeric(:age).using(@valid_attributes)
0
 
0
 
0
 You can group multiple validation checks together like so:
0
+
0
   using(@valid_attributes) do
0
     Model.should need(:name)
0
     Model.should limit_length_of(:name).to(255)
0
@@ -45,16 +54,20 @@ You can group multiple validation checks together like so:
0
 Also allows confirmation of the presence of associations
0
 
0
 Test @belongs_to :parent@
0
+
0
   Model.should belong_to(:parent)
0
 
0
 Test @belongs_to :parent, :class_name => "CustomClass", :foreign_key => "some_id"@
0
+
0
   Model.should belong_to(:parent).with_options(
0
     :class_name => "CustomClass", :foreign_key => "some_id")
0
 
0
 Test @has_many :items@
0
+
0
   Model.should have_many(:items)
0
 
0
 Test @has_many :items, :class_name => "CustomClass", :foreign_key => "some_id"@
0
+
0
   Model.should have_many(:items).with_options(
0
     :class_name => "CustomClass", :foreign_key => "some_id")
0
     
...
20
21
22
23
 
24
25
26
...
30
31
32
33
 
34
35
36
...
20
21
22
 
23
24
25
26
...
30
31
32
 
33
34
35
36
0
@@ -20,7 +20,7 @@ spec = Gem::Specification.new do |s|
0
   s.platform = Gem::Platform::RUBY
0
   s.rubyforge_project = GEM
0
   s.has_rdoc = true
0
- s.extra_rdoc_files = ['README','LICENSE']
0
+ s.extra_rdoc_files = ['README.textile','LICENSE']
0
   s.summary = SUMMARY
0
   s.description = s.summary
0
   s.author = AUTHOR
0
@@ -30,7 +30,7 @@ spec = Gem::Specification.new do |s|
0
   s.add_dependency 'activerecord'
0
   
0
   s.require_path = 'lib'
0
- s.files = %w(README LICENSE Rakefile init.rb) + Dir.glob("{lib,specs}/**/*")
0
+ s.files = %w(README.textile LICENSE Rakefile init.rb) + Dir.glob("{lib,specs}/**/*")
0
 end
0
 
0
 Rake::GemPackageTask.new(spec) do |pkg|

Comments

    No one has commented yet.