Skip to content

Commit

Permalink
Group specs separately for IO#autoclose? and IO#autoclose=
Browse files Browse the repository at this point in the history
  • Loading branch information
seven1m committed Jun 11, 2024
1 parent 8363787 commit e1b9ef3
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions core/io/autoclose_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

describe "IO#autoclose" do
describe "IO#autoclose?" do
before :each do
@io = IOSpecs.io_fixture "lines.txt"
end
Expand All @@ -15,6 +15,22 @@
@io.should.autoclose?
end

it "cannot be queried on a closed IO object" do
@io.close
-> { @io.autoclose? }.should raise_error(IOError, /closed stream/)
end
end

describe "IO#autoclose=" do
before :each do
@io = IOSpecs.io_fixture "lines.txt"
end

after :each do
@io.autoclose = true unless @io.closed?
@io.close unless @io.closed?
end

it "can be set to true" do
@io.autoclose = false
@io.autoclose = true
Expand Down Expand Up @@ -54,11 +70,6 @@
@io.should.autoclose?
end

it "cannot be queried on a closed IO object" do
@io.close
-> { @io.autoclose? }.should raise_error(IOError, /closed stream/)
end

it "cannot be set on a closed IO object" do
@io.close
-> { @io.autoclose = false }.should raise_error(IOError, /closed stream/)
Expand Down

0 comments on commit e1b9ef3

Please sign in to comment.