Skip to content

Commit d5938fa

Browse files
committed
specs: add x-pack to load path since we cannot rely on LS::Runner
1 parent 8d7d24d commit d5938fa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

spec/spec_helper.rb

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
require "rspec/mocks"
33
require "logstash/devutils/rspec/spec_helper"
44

5+
# Since we use Logstash's x-pack WITHOUT the LogStash::Runner,
6+
# we must find it relative to logstash-core and add it to the load path.
7+
require 'pathname'
8+
logstash_core_path = Gem.loaded_specs['logstash-core']&.full_gem_path or fail("logstash-core lib not found")
9+
logstash_xpack_load_path = Pathname.new(logstash_core_path).join("../x-pack/lib").cleanpath.to_s
10+
unless $LOAD_PATH.include?(logstash_xpack_load_path)
11+
$stderr.puts("ADDING LOGSTASH X-PACK to load path: #{logstash_xpack_load_path}")
12+
$LOAD_PATH.unshift(logstash_xpack_load_path)
13+
end
14+
515
module SpecHelper
616

717
def get_host_port_for_es_client

0 commit comments

Comments
 (0)