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