Skip to content

Instantly share code, notes, and snippets.

@dgolombek
Last active July 2, 2020 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgolombek/3123d5602ff6d76e96f2bac01b570210 to your computer and use it in GitHub Desktop.
Save dgolombek/3123d5602ff6d76e96f2bac01b570210 to your computer and use it in GitHub Desktop.
JRuby enum spec bug
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