Skip to content

Commit a6d3e90

Browse files
committed
Add tests for Generic.
1 parent 8dcb5e6 commit a6d3e90

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lib/io/stream/generic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def close
3535
return if closed?
3636

3737
begin
38-
flush
38+
self.flush
3939
rescue
4040
# We really can't do anything here unless we want #close to raise exceptions.
4141
ensure

test/io/stream/generic.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2025, by Samuel Williams.
5+
6+
require "io/stream/generic"
7+
8+
describe IO::Stream::Generic do
9+
let(:stream) {subject.new}
10+
11+
with "#closed?" do
12+
it "should return false by default" do
13+
expect(stream.closed?).to be_falsey
14+
end
15+
end
16+
17+
with "#read" do
18+
it "should raise NotImplementedError" do
19+
expect{stream.read(10)}.to raise_exception(NotImplementedError)
20+
end
21+
end
22+
23+
with "#flush" do
24+
it "should raise NotImplementedError" do
25+
expect{stream.write("hello"); stream.flush}.to raise_exception(NotImplementedError)
26+
end
27+
end
28+
29+
with "#close" do
30+
it "should raise NotImplementedError" do
31+
expect{stream.close}.to raise_exception(NotImplementedError)
32+
end
33+
end
34+
end

0 commit comments

Comments
 (0)