Sha256: b2c9d80016d666a0b6be34b82d3d703aa5455b95522f462763c66e37376775d6

Contents?: true

Size: 1.91 KB

Versions: 100

Compression:

Stored size: 1.91 KB

Contents

# encoding: utf-8
require "spec_helper"
require "logstash/environment"

describe LogStash::Environment do

  context "when loading jars dependencies" do

    let(:default_jars_location)    { File.join("vendor", "jar-dependencies") }
    let(:default_runtime_location) { File.join(default_jars_location,"runtime-jars","*.jar") }
    let(:default_test_location)    { File.join(default_jars_location,"test-jars","*.jar") }

    it "raises an exception if jruby is not available" do
      expect(subject).to receive(:jruby?).and_return(false)
      expect { subject.load_runtime_jars! }.to raise_error
    end

    it "find runtime jars in the default location" do
      expect(subject).to receive(:find_jars).with(default_runtime_location).and_return([])
      subject.load_runtime_jars!
    end

    it "find test jars in the default location" do
      expect(subject).to receive(:find_jars).with(default_test_location).and_return([])
      subject.load_test_jars!
    end

    context "when loading a jar file" do

      let(:dummy_jar_file) { File.join(default_jars_location,"runtime-jars","elasticsearch.jar") }

      it "requires the jar files if there are jars to load" do
        expect(subject).to receive(:find_jars).with(default_runtime_location).and_return([dummy_jar_file])
        expect(subject).to receive(:require).with(dummy_jar_file)
        subject.load_runtime_jars!
      end

      it "raises an exception if there are no jars to load" do
        allow(Dir).to receive(:glob).and_return([])
        expect { subject.load_runtime_jars! }.to raise_error
      end
    end
  end

  context "add_plugin_path" do
    let(:path) { "/some/path" }

    before(:each) { expect($LOAD_PATH).to_not include(path) }
    after(:each) { $LOAD_PATH.delete(path) }

    it "should add the path to $LOAD_PATH" do
      expect{subject.add_plugin_path(path)}.to change{$LOAD_PATH.size}.by(1)
      expect($LOAD_PATH).to include(path)
    end
  end
end

Version data entries

100 entries across 97 versions & 8 rubygems

Version Path
logstash-core-2.4.0-java spec/logstash/environment_spec.rb
logstash-core-2.4.0.snapshot4-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.alpha6.snapshot5-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.alpha6.snapshot4-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.alpha6.snapshot3-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.alpha6.snapshot2-java spec/logstash/environment_spec.rb
logstash-core-2.4.0.snapshot3-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.alpha6.snapshot1-java spec/logstash/environment_spec.rb
logstash-core-2.4.0.snapshot2-java spec/logstash/environment_spec.rb
logstash-core-2.4.0.snapshot1-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.alpha5.snapshot1-java spec/logstash/environment_spec.rb
logstash-core-2.3.4-java spec/logstash/environment_spec.rb
logstash-core-2.3.4.snapshot1-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.alpha4.snapshot3-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.alpha4.snapshot2-java spec/logstash/environment_spec.rb
logstash-core-2.3.3-java spec/logstash/environment_spec.rb
logstash-core-2.3.3.snapshot2-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.alpha4.snapshot1-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.alpha3-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.alpha3.snapshot8-java spec/logstash/environment_spec.rb