summaryrefslogtreecommitdiff
path: root/spec/ruby/library/stringio/truncate_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/stringio/truncate_spec.rb')
-rw-r--r--spec/ruby/library/stringio/truncate_spec.rb20
1 files changed, 6 insertions, 14 deletions
diff --git a/spec/ruby/library/stringio/truncate_spec.rb b/spec/ruby/library/stringio/truncate_spec.rb
index ba910ee98c..592ca5a6e1 100644
--- a/spec/ruby/library/stringio/truncate_spec.rb
+++ b/spec/ruby/library/stringio/truncate_spec.rb
@@ -3,13 +3,11 @@ require "stringio"
describe "StringIO#truncate when passed [length]" do
before :each do
- @io = StringIO.new('123456789')
+ @io = StringIO.new(+'123456789')
end
- # TODO: Report to Ruby-Core: The RDoc says it always returns 0
- it "returns the passed length" do
- @io.truncate(4).should eql(4)
- @io.truncate(10).should eql(10)
+ it "returns an Integer" do
+ @io.truncate(4).should be_kind_of(Integer)
end
it "truncated the underlying string down to the passed length" do
@@ -18,7 +16,7 @@ describe "StringIO#truncate when passed [length]" do
end
it "does not create a copy of the underlying string" do
- io = StringIO.new(str = "123456789")
+ io = StringIO.new(str = +"123456789")
io.truncate(4)
io.string.should equal(str)
end
@@ -47,12 +45,6 @@ describe "StringIO#truncate when passed [length]" do
@io.string.should == "1234"
end
- it "returns the passed length Object, NOT the result of #to_int" do
- obj = mock("to_int")
- obj.should_receive(:to_int).and_return(4)
- @io.truncate(obj).should equal(obj)
- end
-
it "raises a TypeError when the passed length can't be converted to an Integer" do
-> { @io.truncate(Object.new) }.should raise_error(TypeError)
end
@@ -60,10 +52,10 @@ end
describe "StringIO#truncate when self is not writable" do
it "raises an IOError" do
- io = StringIO.new("test", "r")
+ io = StringIO.new(+"test", "r")
-> { io.truncate(2) }.should raise_error(IOError)
- io = StringIO.new("test")
+ io = StringIO.new(+"test")
io.close_write
-> { io.truncate(2) }.should raise_error(IOError)
end