spec/channel_spec.rb in agent-0.11.0 vs spec/channel_spec.rb in agent-0.12.0

- old
+ new

@@ -77,11 +77,11 @@ end end context "closing" do before do - @c = channel!(String) + @c = channel!(Integer, 3) end it "not raise an error the first time it is called" do expect { @c.close }.not_to raise_error expect(@c).to be_closed @@ -109,9 +109,19 @@ expect { @c.send("a") }.to raise_error(Agent::Errors::ChannelClosed) end it "should return [nil, false] when receiving from a channel that has already been closed" do @c.close + expect(@c.receive).to eq([nil, false]) + end + + it "should return buffered items from a closed channel" do + @c << 1 + @c << 2 + @c.close + expect(@c.receive).to eq([1, true]) + expect(@c.receive).to eq([2, true]) + expect(@c.receive).to eq([nil, false]) expect(@c.receive).to eq([nil, false]) end end context "deadlock" do