-
-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate specs for Enumerator#each_with_index and Enumerator#with_index #1168
Conversation
core/enumerator/with_index_spec.rb
Outdated
arr.delete_if.with_index { |a,b| a == 1 || b == 1} | ||
arr.should == [3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only addition to the moved specs, I wanted to include a small test for the actual behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subjective: with_index { |a,b| true }
seems simpler to me (instead of a == 1 || b == 1
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And it does make things a bit more consistent as well, I've updated this one.
it "returns the iterator's return value" do | ||
[1,2,3].select.with_index { |a,b| false }.should == [] | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually #each_with_index
behaves in the same way, so it makes sense to have these two cases here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this one back in, but changed to each_with_index
. Added an extra test to check the true-block as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you think the second test "passes on the given block's return value"
also makes sense to add back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sound very sensible as well, added that one too.
92a271d
to
a2dda88
Compare
A couple of them were defined in the wrong file.
a2dda88
to
123cfbd
Compare
Thank you! |
A couple of them were defined in the wrong file.