From 26bc517afe58e9dce7d32e816c0167427fa2bca5 Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Thu, 3 May 2018 14:19:03 -0700 Subject: [PATCH] Add a test to identify when JRuby fixes lazy enumeration --- spec/result_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/result_spec.rb b/spec/result_spec.rb index 5aadc302..7ea7f8b1 100644 --- a/spec/result_spec.rb +++ b/spec/result_spec.rb @@ -143,4 +143,20 @@ RSpec.describe Capybara::Result do end end end + + context 'lazy select', :focus_ do + it 'is compatible' do + # This test will let us know when JRuby fixes lazy select so we can re-enable it in Result + pending 'JRuby has an issue with lazy enumberator evaluation' if RUBY_PLATFORM == 'java' + eval_count = 0 + enum = ["Text1", "Text2", "Text3"].lazy.select do |t| + eval_count += 1 + true + end + expect(eval_count).to eq 0 + enum.next + sleep 1 + expect(eval_count).to eq 1 + end + end end