Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions library/stringio/each_line_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
describe "StringIO#each_line when self is not readable" do
it_behaves_like :stringio_each_not_readable, :each_line
end

ruby_version_is "2.4" do
describe "StringIO#each_line when passed chomp" do
it_behaves_like :stringio_each_chomp, :each_line
end
end
6 changes: 6 additions & 0 deletions library/stringio/each_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
describe "StringIO#each when self is not readable" do
it_behaves_like :stringio_each_not_readable, :each
end

ruby_version_is "2.4" do
describe "StringIO#each when passed chomp" do
it_behaves_like :stringio_each_chomp, :each
end
end
9 changes: 9 additions & 0 deletions library/stringio/gets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,12 @@
lambda { io.gets }.should raise_error(IOError)
end
end

ruby_version_is "2.4" do
describe "StringIO#gets when passed [chomp]" do
it "returns the data read without a trailing newline character" do
io = StringIO.new("this>is>an>example\n")
io.gets(chomp: true).should == "this>is>an>example"
end
end
end
6 changes: 6 additions & 0 deletions library/stringio/lines_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
describe "StringIO#lines when self is not readable" do
it_behaves_like :stringio_each_not_readable, :lines
end

ruby_version_is "2.4" do
describe "StringIO#lines when passed chomp" do
it_behaves_like :stringio_each_chomp, :lines
end
end
9 changes: 9 additions & 0 deletions library/stringio/readline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,12 @@
lambda { io.readline }.should raise_error(IOError)
end
end

ruby_version_is "2.4" do
describe "StringIO#readline when passed [chomp]" do
it "returns the data read without a trailing newline character" do
io = StringIO.new("this>is>an>example\n")
io.readline(chomp: true).should == "this>is>an>example"
end
end
end
9 changes: 9 additions & 0 deletions library/stringio/readlines_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,12 @@
lambda { io.readlines }.should raise_error(IOError)
end
end

ruby_version_is "2.4" do
describe "StringIO#readlines when passed [chomp]" do
it "returns the data read without a trailing newline character" do
io = StringIO.new("this>is>an>example\n")
io.readlines(chomp: true).should == ["this>is>an>example"]
end
end
end
9 changes: 9 additions & 0 deletions library/stringio/shared/each.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,12 @@
lambda { io.send(@method) { |b| b } }.should raise_error(IOError)
end
end

describe :stringio_each_chomp, shared: true do
it "yields each line with removed newline characters to the passed block" do
seen = []
io = StringIO.new("a b c d e\n1 2 3 4 5")
io.send(@method, chomp: true) {|s| seen << s }
seen.should == ["a b c d e", "1 2 3 4 5"]
end
end