public
Description: My assistance repo w/ minor tweaks (original @ http://assistance.rubyforge.org/svn/trunk)
Homepage: http://assistance.rubyforge.org
Clone URL: git://github.com/bricooke/assistance.git
Search Repo:
Make the errors object enumerable. This was done for merb's error helper
bricooke (author)
Sat Mar 08 05:34:24 -0800 2008
commit  3b8c4fcebb0b2a76667ddc0e87ab7fb84cf14fad
tree    e0c2add033d1524dba607f4f7f4bfed30cfbd99b
parent  ca2dac75a2059fec0249e8b0467f646aedddf003
...
38
39
40
 
 
 
 
 
 
 
 
 
 
 
 
41
42
43
...
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
0
@@ -38,6 +38,18 @@
0
 
0
   # Validation::Errors represents validation errors.
0
   class Errors
0
+ include Enumerable
0
+
0
+ def size
0
+ @errors.size
0
+ end
0
+
0
+ def each
0
+ @errors.each do |error|
0
+ yield error
0
+ end
0
+ end
0
+
0
     # Initializes a new instance of validation errors.
0
     def initialize
0
       @errors = Hash.new {|h, k| h[k] = []}
...
50
51
52
 
 
 
 
 
 
 
 
 
 
53
54
55
...
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
0
@@ -50,6 +50,16 @@
0
     msgs.size.should == 3
0
     msgs.should include('blow blieuh', 'blow blich', 'blay bliu')
0
   end
0
+
0
+ specify "should be enumerable" do
0
+ @errors[:blow] << 'blieuh'
0
+ @errors[:blow] << 'blich'
0
+ @errors[:blay] << 'bliu'
0
+ @errors.size.should == 2
0
+ self.should_receive(:hello).exactly(2)
0
+ @errors.each {|e| self.hello}
0
+ end
0
+
0
 end
0
 
0
 describe Validation do

Comments

    No one has commented yet.