Permalink
Browse files

Set the default payload to be the empty string rather than nil.

  • Loading branch information...
1 parent 55f7d12 commit f0c688dfc4734f85205d861a7c85b08036ae231f Liam Stewart committed Sep 11, 2012
Showing with 5 additions and 1 deletion.
  1. +1 −1 lib/kafka/message.rb
  2. +4 −0 spec/message_spec.rb
View
@@ -42,7 +42,7 @@ class Message
def initialize(payload = nil, magic = MAGIC_IDENTIFIER_DEFAULT, checksum = nil)
self.magic = magic
- self.payload = payload
+ self.payload = payload || ""
self.checksum = checksum || self.calculate_checksum
end
View
@@ -40,6 +40,10 @@
@message.magic.should eql(1)
end
+ it "should have an empty payload by default" do
+ @message.payload.should == ""
+ end
+
it "should calculate the checksum (crc32 of a given message)" do
@message.payload = "ale"
@message.calculate_checksum.should eql(1120192889)

0 comments on commit f0c688d

Please sign in to comment.