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.3-java spec/logstash/settings/time_value_spec.rb
logstash-core-7.3.1-java spec/logstash/settings/time_value_spec.rb
logstash-core-7.3.0-java spec/logstash/settings/time_value_spec.rb
logstash-core-6.8.2-java spec/logstash/settings/time_value_spec.rb
logstash-core-7.2.1-java spec/logstash/settings/time_value_spec.rb
logstash-core-7.2.0-java spec/logstash/settings/time_value_spec.rb
logstash-core-6.8.1-java spec/logstash/settings/time_value_spec.rb
logstash-core-7.1.1-java spec/logstash/settings/time_value_spec.rb
logstash-core-7.1.0-java spec/logstash/settings/time_value_spec.rb
logstash-core-6.8.0-java spec/logstash/settings/time_value_spec.rb
logstash-core-6.7.2-java spec/logstash/settings/time_value_spec.rb
logstash-core-7.0.1-java spec/logstash/settings/time_value_spec.rb
logstash-core-7.0.0-java spec/logstash/settings/time_value_spec.rb
logstash-core-6.7.1-java spec/logstash/settings/time_value_spec.rb
logstash-core-7.0.0.rc2-java spec/logstash/settings/time_value_spec.rb
logstash-core-7.0.0.rc1-java spec/logstash/settings/time_value_spec.rb
logstash-core-6.7.0-java spec/logstash/settings/time_value_spec.rb
logstash-core-5.6.16-java spec/logstash/settings/time_value_spec.rb
logstash-core-6.6.2-java spec/logstash/settings/time_value_spec.rb
logstash-core-6.6.1-java spec/logstash/settings/time_value_spec.rb