From 1e2f1b86e4396f902b2c98be65bf8e3d6cdb0f17 Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Thu, 11 Apr 2019 15:01:59 -0700 Subject: [PATCH] Update to JRuby 9.2.7.0 --- .travis.yml | 2 +- lib/capybara/result.rb | 4 ++-- lib/capybara/spec/session/node_spec.rb | 2 +- spec/result_spec.rb | 16 ++++++++++------ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 37f5d720..d843d373 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ services: - docker rvm: - 2.6 - - jruby-9.2.6.0 + - jruby-9.2.7.0 gemfile: - Gemfile env: diff --git a/lib/capybara/result.rb b/lib/capybara/result.rb index 0eea2891..10bdcd6c 100644 --- a/lib/capybara/result.rb +++ b/lib/capybara/result.rb @@ -149,10 +149,10 @@ module Capybara end def lazy_select_elements(&block) - # JRuby has an issue with lazy enumerators which + # JRuby < 9.2.8.0 has an issue with lazy enumerators which # causes a concurrency issue with network requests here # https://github.com/jruby/jruby/issues/4212 - if RUBY_PLATFORM == 'java' + if (RUBY_PLATFORM == 'java') && (Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('9.2.8.0')) @elements.select(&block).to_enum # non-lazy evaluation else @elements.lazy.select(&block) diff --git a/lib/capybara/spec/session/node_spec.rb b/lib/capybara/spec/session/node_spec.rb index 81e5ca40..d4a7d1ff 100644 --- a/lib/capybara/spec/session/node_spec.rb +++ b/lib/capybara/spec/session/node_spec.rb @@ -195,7 +195,7 @@ Capybara::SpecHelper.spec 'node' do it 'should see a disabled fieldset as disabled' do @session.visit('/form') - expect(@session.find(:css, '#form_disabled_fieldset')).to be_disabled + expect(@session.find(:xpath, './/fieldset[@id="form_disabled_fieldset"]')).to be_disabled end context 'in a disabled fieldset' do diff --git a/spec/result_spec.rb b/spec/result_spec.rb index 358bcf38..a0048ae0 100644 --- a/spec/result_spec.rb +++ b/spec/result_spec.rb @@ -106,7 +106,7 @@ RSpec.describe Capybara::Result do # Not a great test but it indirectly tests what is needed it 'should evaluate filters lazily for idx' do - skip 'JRuby has an issue with lazy enumerator evaluation' if RUBY_PLATFORM == 'java' + skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround? # Not processed until accessed expect(result.instance_variable_get('@result_cache').size).to be 0 @@ -127,7 +127,7 @@ RSpec.describe Capybara::Result do end it 'should evaluate filters lazily for range' do - skip 'JRuby has an issue with lazy enumerator evaluation' if RUBY_PLATFORM == 'java' + skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround? result[0..1] expect(result.instance_variable_get('@result_cache').size).to be 2 @@ -136,7 +136,7 @@ RSpec.describe Capybara::Result do end it 'should evaluate filters lazily for idx and length' do - skip 'JRuby has an issue with lazy enumerator evaluation' if RUBY_PLATFORM == 'java' + skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround? result[1, 2] expect(result.instance_variable_get('@result_cache').size).to be 3 @@ -145,7 +145,7 @@ RSpec.describe Capybara::Result do end it 'should only need to evaluate one result for any?' do - skip 'JRuby has an issue with lazy enumerator evaluation' if RUBY_PLATFORM == 'java' + skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround? result.any? expect(result.instance_variable_get('@result_cache').size).to be 1 end @@ -158,7 +158,7 @@ RSpec.describe Capybara::Result do context '#each' do it 'lazily evaluates' do - skip 'JRuby has an issue with lazy enumerator evaluation' if RUBY_PLATFORM == 'java' + skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround? results = [] result.each do |el| results << el @@ -174,7 +174,7 @@ RSpec.describe Capybara::Result do end it 'lazily evaluates' do - skip 'JRuby has an issue with lazy enumerator evaluation' if RUBY_PLATFORM == 'java' + skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround? result.each.with_index do |_el, idx| expect(result.instance_variable_get('@result_cache').size).to eq(idx + 1) # 0 indexing end @@ -197,4 +197,8 @@ RSpec.describe Capybara::Result do expect(eval_count).to eq 1 end end + + def jruby_lazy_enumerator_workaround? + (RUBY_PLATFORM == 'java') && (Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('9.2.8.0')) + end end