spec/cloudist/payload_spec.rb in cloudist-0.2.1 vs spec/cloudist/payload_spec.rb in cloudist-0.4.1

- old
+ new

@@ -63,11 +63,11 @@ payload[:bread].should == 'white' end it "should format payload for sending" do payload = Cloudist::Payload.new({:bread => 'white'}, {:event_hash => 'foo', :message_type => 'reply'}) - body, popts = payload.formatted + body, popts = payload.to_a headers = popts[:headers] body.should == Marshal.dump({:bread => 'white'}) headers[:ttl].should == "300" headers[:message_type].should == 'reply' @@ -102,14 +102,14 @@ payload = Cloudist::Payload.new({:bread => 'white'}) payload.headers[:reply_to].should be_nil payload.set_reply_to("my_custom_queue") payload.headers[:reply_to].should_not be_nil - payload.headers[:reply_to].should match /^temp\.reply\.my_custom_queue\.(.+)/ - body, headers = payload.formatted + payload.headers[:reply_to].should match /^temp\.reply\.my_custom_queue/ + body, popts = payload.to_a + headers = popts[:headers] headers[:reply_to].should == payload.headers[:reply_to] - end it "should not overwrite passed in headers" do payload = Cloudist::Payload.new({:bread => 'white'}, {:ttl => 25, :event_hash => 'foo', :published_on => 12345, :message_id => 1}) payload.headers[:ttl].should == "25" @@ -124,8 +124,14 @@ end it "should be able to transport an error" do e = ArgumentError.new("FAILED") payload = Cloudist::Payload.new(e, {:message_type => 'error'}) + end + + it "should be able to query payload keys with key?" do + payload = Cloudist::Payload.new({:bread => 'white'}, {:ttl => 25, :event_hash => 'foo', :published_on => 12345, :message_id => 1}) + payload.bread?.should be_true + payload.cheese?.should be_false end end \ No newline at end of file