From 49b335729c93cf660b80695852dae6a97878ab5b Mon Sep 17 00:00:00 2001 From: Emily Giurleo Date: Tue, 3 Nov 2020 11:03:37 -0500 Subject: [PATCH 1/5] Fix shared protocol specs on jruby --- spec/support/shared/protocol.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/support/shared/protocol.rb b/spec/support/shared/protocol.rb index 2933eef893..b2a8930eca 100644 --- a/spec/support/shared/protocol.rb +++ b/spec/support/shared/protocol.rb @@ -5,7 +5,8 @@ describe 'length' do let(:field) { bytes.to_s[0..3] } it 'serializes the length' do - expect(field).to be_int32(bytes.length) + bytes.rewind! + expect(field).to be_int32(bytes.to_s.length) end end From 8971492b6b9012888c67295220653ac2f37ef87d Mon Sep 17 00:00:00 2001 From: Emily Giurleo Date: Tue, 3 Nov 2020 13:05:12 -0500 Subject: [PATCH 2/5] Remove pending for issue that was resolvedin bson 4.11.0 --- spec/integration/bson_symbol_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/integration/bson_symbol_spec.rb b/spec/integration/bson_symbol_spec.rb index 7292cb249f..a544e42c19 100644 --- a/spec/integration/bson_symbol_spec.rb +++ b/spec/integration/bson_symbol_spec.rb @@ -25,10 +25,6 @@ end it 'round-trips symbol values using the same byte buffer' do - if BSON::Environment.jruby? - pending 'https://jira.mongodb.org/browse/RUBY-2128' - end - Hash.from_bson(hash.to_bson).should == hash end end From 55751bbb16663ff8e80465502447dcf997c7acb7 Mon Sep 17 00:00:00 2001 From: Emily Giurleo Date: Tue, 3 Nov 2020 14:56:08 -0500 Subject: [PATCH 3/5] Add conditional behavior on jruby --- spec/support/shared/protocol.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/shared/protocol.rb b/spec/support/shared/protocol.rb index b2a8930eca..bac8cd95ba 100644 --- a/spec/support/shared/protocol.rb +++ b/spec/support/shared/protocol.rb @@ -5,7 +5,7 @@ describe 'length' do let(:field) { bytes.to_s[0..3] } it 'serializes the length' do - bytes.rewind! + bytes.rewind! if BSON::Environment.jruby? expect(field).to be_int32(bytes.to_s.length) end end From ac2c14ad0d9f5fc5027c0d0bf20ab2aa15d63b2e Mon Sep 17 00:00:00 2001 From: Emily Giurleo Date: Tue, 3 Nov 2020 16:37:46 -0500 Subject: [PATCH 4/5] Only run the bson symbol test when the BSON gem supports that functionality --- spec/integration/bson_symbol_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/integration/bson_symbol_spec.rb b/spec/integration/bson_symbol_spec.rb index a544e42c19..dbe834de95 100644 --- a/spec/integration/bson_symbol_spec.rb +++ b/spec/integration/bson_symbol_spec.rb @@ -25,6 +25,12 @@ end it 'round-trips symbol values using the same byte buffer' do + if BSON::Environment.jruby? && BSON::VERSION < "4.11.0" + skip 'This test is only relevant to bson versions that increment ByteBuffer '\ + 'read and write positions separately in JRuby, as implemented in ' \ + 'bson version 4.11.0. For more information, see https://jira.mongodb.org/browse/RUBY-2128' + end + Hash.from_bson(hash.to_bson).should == hash end end From f4992ae6e67673b15fa3055bc11c45b446bb8a9a Mon Sep 17 00:00:00 2001 From: Emily Giurleo Date: Wed, 4 Nov 2020 11:17:36 -0500 Subject: [PATCH 5/5] Revert change and rely on BSON fix --- spec/support/shared/protocol.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/support/shared/protocol.rb b/spec/support/shared/protocol.rb index bac8cd95ba..2933eef893 100644 --- a/spec/support/shared/protocol.rb +++ b/spec/support/shared/protocol.rb @@ -5,8 +5,7 @@ describe 'length' do let(:field) { bytes.to_s[0..3] } it 'serializes the length' do - bytes.rewind! if BSON::Environment.jruby? - expect(field).to be_int32(bytes.to_s.length) + expect(field).to be_int32(bytes.length) end end