spec/selector_spec.rb in agent-0.9.1 vs spec/selector_spec.rb in agent-0.10.0
- old
+ new
@@ -106,21 +106,30 @@
r.size.should == 1
r.first.should == :default
end
- it "should raise an error if the channel is closed out from under it" do
+ it "should raise an error if the channel is closed out from under it and you are sending to it" do
go!{ sleep 0.25; @c.close }
lambda {
select! do |s|
s.case(@c, :send, 1)
- s.case(@c, :receive)
end
}.should raise_error(Agent::Errors::ChannelClosed)
end
+ it "should not raise an error if the channel is closed out from under it and you are receiving from it" do
+ go!{ sleep 0.25; @c.close }
+
+ lambda {
+ select! do |s|
+ s.case(@c, :receive){}
+ end
+ }.should_not raise_error
+ end
+
context "select immediately available channel" do
it "should select read channel" do
c = channel!(Integer)
go!{ c.send(1) }
@@ -289,20 +298,29 @@
r.size.should == 1
r.first.should == :default
end
- it "should raise an error if the channel is closed out from under it" do
+ it "should raise an error if the channel is closed out from under it and you are sending to it" do
@c.send(1)
go!{ sleep 0.25; @c.close }
lambda {
select! do |s|
s.case(@c, :send, 1)
- s.case(@c, :send, 2)
end
}.should raise_error(Agent::Errors::ChannelClosed)
+ end
+
+ it "should not raise an error if the channel is closed out from under it and you are receiving from it" do
+ go!{ sleep 0.25; @c.close }
+
+ lambda {
+ select! do |s|
+ s.case(@c, :receive){}
+ end
+ }.should_not raise_error
end
context "select immediately available channel" do
it "should select read channel" do
c = channel!(Integer, 1)