Sha256: 12a05e88db93a79f36734112337eb9f4a80b16c69814aa5b86e54432f9918878

Contents?: true

Size: 987 Bytes

Versions: 164

Compression:

Stored size: 987 Bytes

Contents

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

describe LogStash::Setting::TimeValue do
  subject { described_class.new("option", "-1") }
  describe "#set" do
    it "should coerce the default correctly" do
      expect(subject.value).to eq(LogStash::Util::TimeValue.new(-1, :nanosecond).to_nanos)
    end

    context "when a value is given outside of possible_values" do
      it "should raise an ArgumentError" do
        expect { subject.set("invalid") }.to raise_error(ArgumentError)
      end
    end
    context "when a value is given as a time value" do
      it "should set the value" do
        subject.set("18m")
        expect(subject.value).to eq(LogStash::Util::TimeValue.new(18, :minute).to_nanos)
      end
    end

    context "when a value is given as a nanosecond" do
      it "should set the value" do
        subject.set(5)
        expect(subject.value).to eq(LogStash::Util::TimeValue.new(5, :nanosecond).to_nanos)
      end
    end
  end
end

Version data entries

164 entries across 161 versions & 11 rubygems

Version Path
logstash-core-6.8.23-java spec/logstash/settings/time_value_spec.rb
logstash-core-6.8.22-java spec/logstash/settings/time_value_spec.rb
logstash-core-6.8.21-java spec/logstash/settings/time_value_spec.rb
logstash-core-6.8.20-java spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb
logstash-core-6.8.19-java spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb
logstash-core-6.8.18-java spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb
logstash-core-6.8.17-java spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/settings/time_value_spec.rb