Last active
July 2, 2020 14:57
-
-
Save dgolombek/3123d5602ff6d76e96f2bac01b570210 to your computer and use it in GitHub Desktop.
JRuby enum spec bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
def check_iter(iter, first) | |
raise "bad first element on first peek, #{iter.peek.id} != #{first.id}" unless iter.peek.id == first.id | |
raise "bad first element on second peek" unless iter.peek.id == first.id | |
raise "bad first element on next" unless iter.next.id == first.id | |
end | |
describe 'Enumerator' do | |
context 'with a single value in an AR array' do | |
it 'should not hang' do | |
obj = FactoryBot.create :device | |
collection = Models::Device.all.to_a | |
check_iter(collection.each, obj) | |
collection = Models::Device.all.to_a | |
check_iter(collection.to_enum, obj) | |
collection = Models::Device.all | |
check_iter(collection.each, obj) | |
collection = Models::Device.all | |
# This one fails | |
check_iter(collection.to_enum, obj) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment