File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ def next
4646 # Required by the Enumerable mixin. Provides an internal iterator over the
4747 # rows of the result set.
4848 def each
49+ return enum_for ( __method__ ) unless block_given?
4950 while ( node = self . next )
5051 yield node
5152 end
Original file line number Diff line number Diff line change @@ -117,6 +117,13 @@ def test_each
117117 assert_equal 2 , called
118118 end
119119
120+ def test_each_enum
121+ called = 0
122+ @result . reset ( 1 , 2 )
123+ @result . each . to_a . each { |row | called += 1 }
124+ assert_equal 2 , called
125+ end
126+
120127 def test_enumerable
121128 @result . reset ( 1 , 2 )
122129 assert_equal 2 , @result . to_a . length
@@ -139,7 +146,7 @@ def test_close
139146 assert_predicate stmt , :closed?
140147 assert_raise ( SQLite3 ::Exception ) { result . reset }
141148 assert_raise ( SQLite3 ::Exception ) { result . next }
142- assert_raise ( SQLite3 ::Exception ) { result . each }
149+ assert_raise ( SQLite3 ::Exception ) { result . each . next }
143150 assert_raise ( SQLite3 ::Exception ) { result . close }
144151 assert_raise ( SQLite3 ::Exception ) { result . types }
145152 assert_raise ( SQLite3 ::Exception ) { result . columns }
You can’t perform that action at this time.
0 commit comments