|
21 | 21 | let(:es_version) { "7.5.0" }
|
22 | 22 | let(:cluster_info) { {"version" => {"number" => es_version, "build_flavor" => build_flavor}, "tagline" => "You Know, for Search"} }
|
23 | 23 |
|
| 24 | + def elastic_ruby_v8_client_available? |
| 25 | + Elasticsearch::Transport |
| 26 | + false |
| 27 | + rescue NameError # NameError: uninitialized constant Elasticsearch::Transport if Elastic Ruby client is not available |
| 28 | + true |
| 29 | + end |
| 30 | + |
24 | 31 | before(:each) do
|
25 | 32 | Elasticsearch::Client.send(:define_method, :ping) { } # define no-action ping method
|
26 | 33 | allow_any_instance_of(Elasticsearch::Client).to receive(:info).and_return(cluster_info)
|
|
92 | 99 |
|
93 | 100 | before do
|
94 | 101 | 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 |
| - ) |
| 102 | + if elastic_ruby_v8_client_available? |
| 103 | + allow(es_client).to receive(:info).and_raise(Elastic::Transport::Transport::Errors::BadRequest.new) |
| 104 | + else |
| 105 | + allow(es_client).to receive(:info).and_raise(Elasticsearch::Transport::Transport::Errors::BadRequest.new) |
| 106 | + end |
98 | 107 | end
|
99 | 108 |
|
100 | 109 | it "raises an exception" do
|
@@ -744,8 +753,13 @@ def synchronize_method!(object, method_name)
|
744 | 753 | it "should set host(s)" do
|
745 | 754 | plugin.register
|
746 | 755 | client = plugin.send(:client)
|
747 |
| - |
748 |
| - expect( client.transport.instance_variable_get(:@seeds) ).to eql [{ |
| 756 | + target_field = :@seeds |
| 757 | + begin |
| 758 | + Elasticsearch::Transport::Client |
| 759 | + rescue |
| 760 | + target_field = :@hosts |
| 761 | + end |
| 762 | + expect( client.transport.instance_variable_get(target_field) ).to eql [{ |
749 | 763 | :scheme => "https",
|
750 | 764 | :host => "ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io",
|
751 | 765 | :port => 9243,
|
|
0 commit comments