spec/channel_spec.rb in agent-0.9.1 vs spec/channel_spec.rb in agent-0.10.0
- old
+ new
@@ -107,13 +107,13 @@
it "should raise an error when sending to a channel that has already been closed" do
@c.close
lambda { @c.send("a") }.should raise_error(Agent::Errors::ChannelClosed)
end
- it "should raise an error when receiving from a channel that has already been closed" do
+ it "should return [nil, false] when receiving from a channel that has already been closed" do
@c.close
- lambda { @c.receive }.should raise_error(Agent::Errors::ChannelClosed)
+ @c.receive.should == [nil, false]
end
end
context "deadlock" do
before do
@@ -211,6 +211,30 @@
cm = Marshal.load(Marshal.dump(@c))
cm.receive[0].should == "hello"
end
end
+ context "marshaling" do
+ it "marshals data by default" do
+ c = channel!(String, 1)
+ string = "foo"
+ c.send(string)
+ string_copy = c.receive[0]
+ string_copy.should == string
+ string_copy.object_id.should_not == string.object_id
+ end
+
+ it "skips marshaling when configured to" do
+ c = channel!(String, 1, :skip_marshal => true)
+ string = "foo"
+ c.send(string)
+ c.receive[0].object_id.should == string.object_id
+ end
+
+ it "skips marshaling for channels by default" do
+ c = channel!(Agent::Channel, 1)
+ c.send(c)
+ c.receive[0].object_id.should == c.object_id
+ end
+ end
end
+