Sha256: 86631abb4030928e78243434e95ecbec00dad42f52e011d029467597bb6a0073

Contents?: true

Size: 1.14 KB

Versions: 11

Compression:

Stored size: 1.14 KB

Contents

# encoding: utf-8

require "spec_helper"
require "logstash/timestamp"

describe LogStash::Timestamp do
  context "constructors" do
    it "should work" do
      t = LogStash::Timestamp.new
      expect(t.time.to_i).to be_within(2).of Time.now.to_i

      t = LogStash::Timestamp.now
      expect(t.time.to_i).to be_within(2).of Time.now.to_i

      now = Time.now.utc
      t = LogStash::Timestamp.new(now)
      expect(t.time).to eq(now)

      t = LogStash::Timestamp.at(now.to_i)
      expect(t.time.to_i).to eq(now.to_i)
    end

    it "should have consistent behaviour across == and .eql?" do
      its_xmas = Time.utc(2015, 12, 25, 0, 0, 0)
      expect(LogStash::Timestamp.new(its_xmas)).to eql(LogStash::Timestamp.new(its_xmas))
      expect(LogStash::Timestamp.new(its_xmas)).to be ==(LogStash::Timestamp.new(its_xmas))
    end

    it "should raise exception on invalid format" do
      expect{LogStash::Timestamp.new("foobar")}.to raise_error
    end

    it "should copy itself correctly on clone and dup" do
      expect(LogStash::Timestamp.now.clone.to_java).not_to be_nil
      expect(LogStash::Timestamp.now.dup.to_java).not_to be_nil
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
logstash-core-5.6.16-java spec/logstash/timestamp_spec.rb
logstash-core-5.6.15-java spec/logstash/timestamp_spec.rb
logstash-core-5.6.14-java spec/logstash/timestamp_spec.rb
logstash-core-5.6.13-java spec/logstash/timestamp_spec.rb
logstash-core-5.6.12-java spec/logstash/timestamp_spec.rb
logstash-core-5.6.11-java spec/logstash/timestamp_spec.rb
logstash-core-5.6.10-java spec/logstash/timestamp_spec.rb
logstash-core-5.6.9-java spec/logstash/timestamp_spec.rb
logstash-core-5.6.8-java spec/logstash/timestamp_spec.rb
logstash-core-5.6.7-java spec/logstash/timestamp_spec.rb
logstash-core-5.6.6-java spec/logstash/timestamp_spec.rb