Sha256: b179957c4b931c8cf8575754ea193fde71aeb06eb761617043f2c740c955e477

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require "spec_helper"

describe Rdkafka::Consumer::Partition do
  let(:offset) { 100 }
  subject { Rdkafka::Consumer::Partition.new(1, offset) }

  it "should have a partition" do
    expect(subject.partition).to eq 1
  end

  it "should have an offset" do
    expect(subject.offset).to eq 100
  end

  describe "#to_s" do
    it "should return a human readable representation" do
      expect(subject.to_s).to eq "<Partition 1 with offset 100>"
    end
  end

  describe "#inspect" do
    it "should return a human readable representation" do
      expect(subject.to_s).to eq "<Partition 1 with offset 100>"
    end

    context "without offset" do
      let(:offset) { nil }

      it "should return a human readable representation" do
        expect(subject.to_s).to eq "<Partition 1 without offset>"
      end
    end
  end

  describe "#==" do
    it "should equal another partition with the same content" do
      expect(subject).to eq Rdkafka::Consumer::Partition.new(1, 100)
    end

    it "should not equal another partition with different content" do
      expect(subject).not_to eq Rdkafka::Consumer::Partition.new(2, 101)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rdkafka-0.4.2 spec/rdkafka/consumer/partition_spec.rb
rdkafka-0.4.1 spec/rdkafka/consumer/partition_spec.rb
rdkafka-0.4.0 spec/rdkafka/consumer/partition_spec.rb