From 94d22fb7069b79442e9a425acac7bbbedc6a8819 Mon Sep 17 00:00:00 2001 From: Andrew Babichev Date: Mon, 11 Dec 2017 12:42:18 +0200 Subject: [PATCH] Parsing behavior for bare schema diverge depending of ruby stdlib version --- spec/amq/uri_parsing_spec.rb | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/spec/amq/uri_parsing_spec.rb b/spec/amq/uri_parsing_spec.rb index 298b903..512b6b7 100644 --- a/spec/amq/uri_parsing_spec.rb +++ b/spec/amq/uri_parsing_spec.rb @@ -27,18 +27,31 @@ context "escaped" do let(:uri) { "amqp://r%61bbitmq:5672" } - it "parses host", pending: '?' do + it "parses host", pending: "Need to investigate, why URI module doesn't handle escaped host component..." do expect(subject[:host]).to eq("rabbitmq") end end end - context "absent" do - let(:uri) { "amqp://" } + if RUBY_VERSION >= "2.2" + context "absent" do + let(:uri) { "amqp://" } - # Note that according to the ABNF, the host component may not be absent, but it may be zero-length. - it "fallbacks to default nil host" do - expect(subject[:host]).to be_nil + # Note that according to the ABNF, the host component may not be absent, but it may be zero-length. + it "fallbacks to default nil host" do + expect(subject[:host]).to be_nil + end + end + end + + if RUBY_VERSION < "2.2" + context "absent" do + let(:uri) { "amqp://" } + + # Note that according to the ABNF, the host component may not be absent, but it may be zero-length. + it "raises InvalidURIError" do + expect { subject[:host] }.to raise_error(InvalidURIError, /bad URI(absolute but no path)/) + end end end end