Sha256: a1f195084ce9853ad65d4b65e769f8e13dff7fd368d523d2dc1cbd71115ae530
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
require "spec_helper" describe Rdkafka::Message do let(:native_topic) do Rdkafka::FFI.rd_kafka_topic_new( native_client, "topic_name", nil ) end let(:payload) { nil } let(:key) { nil } let(:native_message) do Rdkafka::FFI::Message.new.tap do |message| message[:rkt] = native_topic message[:partition] = 3 message[:offset] = 100 if payload ptr = ::FFI::MemoryPointer.new(:char, payload.bytesize) ptr.put_bytes(0, payload) message[:payload] = ptr message[:len] = payload.bytesize end if key ptr = ::FFI::MemoryPointer.new(:char, key.bytesize) ptr.put_bytes(0, key) message[:key] = ptr message[:key_len] = key.bytesize end end end subject { Rdkafka::Message.new(native_message) } it "should have a topic" do expect(subject.topic).to eq "topic_name" end it "should have a partition" do expect(subject.partition).to eq 3 end context "payload" do it "should have a nil payload when none is present" do expect(subject.payload).to be_nil end context "present payload" do let(:payload) { "payload content" } it "should have a payload" do expect(subject.payload).to eq "payload content" end end end context "key" do it "should have a nil key when none is present" do expect(subject.key).to be_nil end context "present key" do let(:key) { "key content" } it "should have a key" do expect(subject.key).to eq "key content" end end end it "should have an offset" do expect(subject.offset).to eq 100 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rdkafka-0.1.10 | spec/rdkafka/message_spec.rb |