Skip to content

Commit 5471b74

Browse files
committed
Fix the unit test failures casued by #223
1 parent b920701 commit 5471b74

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

spec/inputs/elasticsearch_spec.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@
9292

9393
before do
9494
allow(Elasticsearch::Client).to receive(:new).and_return(es_client)
95-
allow(es_client).to receive(:info).and_raise(
96-
Elasticsearch::Transport::Transport::Errors::BadRequest.new
97-
)
95+
begin
96+
allow(es_client).to receive(:info).and_raise(Elasticsearch::Transport::Transport::Errors::BadRequest.new)
97+
rescue NameError # NameError: uninitialized constant Elasticsearch::Transport
98+
allow(es_client).to receive(:info).and_raise(Elastic::Transport::Transport::Errors::BadRequest.new)
99+
end
98100
end
99101

100102
it "raises an exception" do
@@ -744,8 +746,13 @@ def synchronize_method!(object, method_name)
744746
it "should set host(s)" do
745747
plugin.register
746748
client = plugin.send(:client)
747-
748-
expect( client.transport.instance_variable_get(:@seeds) ).to eql [{
749+
target_field = :@seeds
750+
begin
751+
Elasticsearch::Transport::Client
752+
rescue
753+
target_field = :@hosts
754+
end
755+
expect( client.transport.instance_variable_get(target_field) ).to eql [{
749756
:scheme => "https",
750757
:host => "ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io",
751758
:port => 9243,

0 commit comments

Comments
 (0)