Allow calling each, each_hash without block#656
Allow calling each, each_hash without block#656kch wants to merge 6 commits intosparklemotion:mainfrom
Conversation
flavorjones
left a comment
There was a problem hiding this comment.
Thanks for opening this PR! This is a nice quality-of-life improvement. I have just a couple of comments about the test coverage (which I have been trying to improve with every PR).
| def test_each_enum | ||
| called = 0 | ||
| @result.reset(1, 2) | ||
| @result.each.to_a.each { |row| called += 1 } | ||
| assert_equal 2, called | ||
| end |
There was a problem hiding this comment.
I would like this test to also assert that the .each returns an Enumerator object. I'd also like a similar test for .each_hash, something like:
def test_each_enum
@result.reset(1, 2)
enum = @result.each
assert_instance_of Enumerator, enum
assert_equal 2, enum.to_a.length
end
def test_each_hash_enum
@result.reset(1, 2)
enum = @result.each_hash
assert_instance_of Enumerator, enum
assert_equal 2, enum.to_a.length
endThere was a problem hiding this comment.
yeah those are fine, just copied over. I also noticed we should return self when no block, so also added tests for that.
lib/sqlite3/resultset.rb
Outdated
| @@ -46,6 +46,7 @@ def next | |||
| # Required by the Enumerable mixin. Provides an internal iterator over the | |||
| # rows of the result set. | |||
There was a problem hiding this comment.
Please also update the docstring!
lib/sqlite3/resultset.rb
Outdated
| @@ -54,6 +55,7 @@ def each | |||
| # Provides an internal iterator over the rows of the result set where | |||
| # each row is yielded as a hash. | |||
There was a problem hiding this comment.
Please also update the docstring!
|
Sorry for the delay here, I've got a large open-source backlog at the moment and plan to get back to this shortly. |
d9798a9 to
5127f03
Compare
Returns an enumerator. Matching similar methods in ruby stdlib.