Skip to content

Commit 5fc9642

Browse files
authored
Add Tempfile test which can trigger EAGAIN on blocking write.
1 parent 59a8004 commit 5fc9642

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

gems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
gem "bake-gem"
1212
gem "bake-modernize"
1313

14-
gem "utopia-project"#, path: '../utopia-project'
14+
gem "utopia-project"
1515
end
1616

1717
# gem "async-rspec", path: "../async-rspec"

spec/tempfile_spec.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright, 2022, by Samuel G. D. Williams. <http://www.codeotaku.com>
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
23+
require 'tempfile'
24+
25+
RSpec.describe Tempfile do
26+
it "should be able to read and write" do
27+
Sync do
28+
1_000_000.times{subject.write("Hello World!")}
29+
subject.flush
30+
31+
subject.seek(0)
32+
33+
expect(subject.read(12)).to be == "Hello World!"
34+
end
35+
end
36+
end

0 commit comments

Comments
 (0)