Sha256: edd10d22025e715ff8c4c3d2a023e9a3922112e8fad0d66b32ffa02c1eb8dc21

Contents?: true

Size: 902 Bytes

Versions: 3

Compression:

Stored size: 902 Bytes

Contents

# encoding: utf-8
require_relative "../spec_helper"

describe ::LogStash::Timestamp do
  let(:time_array) { [1918,11,11,11,0,0, "+00:00"] }
  let(:a_time) { Time.utc(*time_array) }
  let(:bson_time) { Time.utc(*time_array).to_bson }

  subject(:timestamp) { described_class.new(a_time) }

  it "responds to to_bson" do
    expect(subject).to respond_to(:to_bson)
  end

  it "to_bson returns a binary encoded timestamp which may be encoded back from bson" do
    expect(Time::from_bson(timestamp.to_bson)).to eq(Time::from_bson(bson_time))
  end

  it "bson_type returns a binary encoded 9" do
    expect(subject.bson_type).to eq(a_time.bson_type)
  end

  describe "class methods" do
    it "builds a new Timestamp from BSON" do
      expected = ::LogStash::Timestamp.new(a_time)
      decoded = ::LogStash::Timestamp.from_bson(bson_time)
      expect(decoded <=> expected).to eq(0)
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
logstash-output-mongo-1.0.1 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb-3.1.7 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb-3.1.6 spec/bson/logstash_timestamp_spec.rb