Skip to content

Commit 9b169fd

Browse files
committed
Fix the unit test failures casued by #223
1 parent 3f37223 commit 9b169fd

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
@@ -79,9 +79,11 @@
7979

8080
before do
8181
allow(Elasticsearch::Client).to receive(:new).and_return(es_client)
82-
allow(es_client).to receive(:info).and_raise(
83-
Elasticsearch::Transport::Transport::Errors::BadRequest.new
84-
)
82+
begin
83+
allow(es_client).to receive(:info).and_raise(Elasticsearch::Transport::Transport::Errors::BadRequest.new)
84+
rescue NameError # NameError: uninitialized constant Elasticsearch::Transport
85+
allow(es_client).to receive(:info).and_raise(Elastic::Transport::Transport::Errors::BadRequest.new)
86+
end
8587
end
8688

8789
it "raises an exception" do
@@ -731,8 +733,13 @@ def synchronize_method!(object, method_name)
731733
it "should set host(s)" do
732734
plugin.register
733735
client = plugin.send(:client)
734-
735-
expect( client.transport.instance_variable_get(:@seeds) ).to eql [{
736+
target_field = :@seeds
737+
begin
738+
Elasticsearch::Transport::Client
739+
rescue
740+
target_field = :@hosts
741+
end
742+
expect( client.transport.instance_variable_get(target_field) ).to eql [{
736743
:scheme => "https",
737744
:host => "ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io",
738745
:port => 9243,

0 commit comments

Comments
 (0)