2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
|
|
|
require_relative 'fixtures/classes'
|
|
|
|
require_relative 'shared/tell'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
describe "StringIO#pos" do
|
|
|
|
it_behaves_like :stringio_tell, :pos
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "StringIO#pos=" do
|
|
|
|
before :each do
|
|
|
|
@io = StringIOSpecs.build
|
|
|
|
end
|
|
|
|
|
|
|
|
it "updates the current byte offset" do
|
|
|
|
@io.pos = 26
|
|
|
|
@io.read(1).should == "r"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an EINVAL if given a negative argument" do
|
2017-12-15 12:44:37 -05:00
|
|
|
lambda { @io.pos = -10 }.should raise_error(Errno::EINVAL)
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "updates the current byte offset after reaching EOF" do
|
|
|
|
@io.read
|
|
|
|
@io.pos = 26
|
|
|
|
@io.read(1).should == "r"
|
|
|
|
end
|
|
|
|
end
|