diff options
Diffstat (limited to 'spec/ruby/library/stringio/gets_spec.rb')
| -rw-r--r-- | spec/ruby/library/stringio/gets_spec.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/ruby/library/stringio/gets_spec.rb b/spec/ruby/library/stringio/gets_spec.rb new file mode 100644 index 0000000000..5dc572fba5 --- /dev/null +++ b/spec/ruby/library/stringio/gets_spec.rb @@ -0,0 +1,61 @@ +require_relative '../../spec_helper' +require "stringio" +require_relative "shared/gets" + +describe "StringIO#gets" do + describe "when passed [separator]" do + it_behaves_like :stringio_gets_separator, :gets + + it "returns nil if self is at the end" do + @io = StringIO.new("this>is>an>example") + + @io.pos = 36 + @io.gets(">").should == nil + @io.gets(">").should == nil + end + end + + describe "when passed [limit]" do + it_behaves_like :stringio_gets_limit, :gets + + it "returns nil if self is at the end" do + @io = StringIO.new("this>is>an>example") + + @io.pos = 36 + @io.gets(3).should == nil + @io.gets(3).should == nil + end + end + + describe "when passed [separator] and [limit]" do + it_behaves_like :stringio_gets_separator_and_limit, :gets + + it "returns nil if self is at the end" do + @io = StringIO.new("this>is>an>example") + + @io.pos = 36 + @io.gets(">", 3).should == nil + @io.gets(">", 3).should == nil + end + end + + describe "when passed no argument" do + it_behaves_like :stringio_gets_no_argument, :gets + + it "returns nil if self is at the end" do + @io = StringIO.new("this>is>an>example") + + @io.pos = 36 + @io.gets.should == nil + @io.gets.should == nil + end + end + + describe "when passed [chomp]" do + it_behaves_like :stringio_gets_chomp, :gets + end + + describe "when in write-only mode" do + it_behaves_like :stringio_gets_write_only, :gets + end +end |
