Skip to content

Commit 06cbb91

Browse files
committed
Add code coverage for Async::Container::Channel.
1 parent bc27b98 commit 06cbb91

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/async/container/channel.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2025, by Samuel Williams.
5+
6+
require "async/container/channel"
7+
8+
describe Async::Container::Channel do
9+
let(:channel) {subject.new}
10+
11+
after do
12+
@channel&.close
13+
end
14+
15+
it "can send and receive" do
16+
channel.out.puts "Hello, World!"
17+
18+
expect(channel.in.gets).to be == "Hello, World!\n"
19+
end
20+
21+
it "can send and receive JSON" do
22+
channel.out.puts JSON.dump({hello: "world"})
23+
24+
expect(channel.receive).to be == {hello: "world"}
25+
end
26+
27+
it "can receive invalid JSON" do
28+
channel.out.puts "Hello, World!"
29+
30+
expect(channel.receive).to be == {line: "Hello, World!\n"}
31+
end
32+
end

0 commit comments

Comments
 (0)