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
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/logstash-core-5.0.0-java/spec/logstash/environment_spec.rb
logstash-filter-zabbix-0.1.2 vendor/bundle/jruby/1.9/gems/logstash-core-2.4.1-java/spec/logstash/environment_spec.rb
logstash-filter-zabbix-0.1.1 vendor/bundle/jruby/1.9/gems/logstash-core-2.4.1-java/spec/logstash/environment_spec.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/logstash-core-2.4.1-java/spec/logstash/environment_spec.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/logstash-core-2.4.1-java/spec/logstash/environment_spec.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/logstash-core-2.4.1-java/spec/logstash/environment_spec.rb
logstash-core-5.0.2-java spec/logstash/environment_spec.rb
logstash-core-5.0.1-java spec/logstash/environment_spec.rb
logstash-core-2.4.1-java spec/logstash/environment_spec.rb
logstash-core-5.0.0-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.pre.rc1-java spec/logstash/environment_spec.rb
logstash-core-5.0.0.pre.beta1-java spec/logstash/environment_spec.rb
logstash-filter-delta-1.1.0 vendor/bundle/jruby/2.2.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/environment_spec.rb
logstash-filter-delta-1.0.1 vendor/bundle/jruby/2.2.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/environment_spec.rb
logstash-filter-base64-1.0.4 vendor/bundle/jruby/2.2.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/environment_spec.rb
logstash-filter-base64-1.0.3 vendor/bundle/jruby/2.2.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/environment_spec.rb
logstash-filter-delta-1.0.0 vendor/bundle/jruby/2.2.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/environment_spec.rb
logstash-filter-base64-1.0.2 vendor/bundle/jruby/2.3.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/environment_spec.rb
logstash-filter-base64-1.0.1 vendor/bundle/jruby/2.3.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/environment_spec.rb
logstash-filter-base64-1.0.0 vendor/bundle/jruby/2.3.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/environment_spec.rb