1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
require 'spec_helper'
describe String do
before do
@string = %{
0123456789
012345
01234567
0123
}.tabto(0).strip
end
it "can translate indices to column numbers" do
@string.column_of(0).should == 1
@string.column_of(5).should == 6
@string.column_of(10).should == 11
@string.column_of(11).should == 1
@string.column_of(17).should == 7
@string.column_of(18).should == 1
@string.column_of(24).should == 7
end
it "can translate indices to line numbers" do
@string.line_of(0).should == 1
@string.line_of(5).should == 1
@string.line_of(10).should == 1
@string.line_of(11).should == 2
@string.line_of(17).should == 2
@string.line_of(18).should == 3
@string.line_of(24).should == 3
end
end
|