Skip to content

Commit

Permalink
Merge pull request #1317 from herwinw/io_gets_dollar_underscore
Browse files Browse the repository at this point in the history
Refresh specs for IO#gets
  • Loading branch information
herwinw committed Oct 8, 2023
2 parents 6c27830 + dbac30b commit e0a3e5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 6 additions & 0 deletions spec/core/io/gets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
end
end

it "sets $_ to nil after the last line has been read" do
while @io.gets
end
$_.should be_nil
end

it "returns nil if called at the end of the stream" do
IOSpecs.lines.length.times { @io.gets }
@io.gets.should == nil
Expand Down
11 changes: 0 additions & 11 deletions test/natalie/io_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,3 @@
-> { @io.autoclose = false }.should raise_error(IOError, /closed stream/)
end
end

describe "IO#gets" do
it "sets $_ to nil afthe the last line has been read" do
File.open(__dir__ + '/../../spec/core/io/fixtures/lines.txt') do |f|
while line = f.gets
$_.should == line
end
$_.should be_nil
end
end
end

0 comments on commit e0a3e5f

Please sign in to comment.