Sha256: c527a5b31d5b5472c72e482e8102345da029ca120237cd9a9b2254d68bc6fef4

Contents?: true

Size: 865 Bytes

Versions: 12

Compression:

Stored size: 865 Bytes

Contents

# encoding: utf-8
require_relative "../spec_helper"
require 'stringio'

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" do
    expect(timestamp.to_bson).to eq(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(StringIO.new(bson_time))
      expect(decoded <=> expected).to eq(0)
    end
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
logstash-output-mongodb_custom-0.1.0 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb-3.1.5 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb_3.6-3.1.5 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb-3.1.4 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb-3.1.3 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb-3.1.2 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb-3.1.1 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb-3.1.0 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb-3.0.1 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb-3.0.0 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb-2.0.5 spec/bson/logstash_timestamp_spec.rb
logstash-output-mongodb-2.0.3 spec/bson/logstash_timestamp_spec.rb