Broke dependency on facets and trying to coexist with Rails.
[treetop.git] / spec / ruby_extensions / string_spec.rb
blob1b293f5717bbf45ee7cd3e87bd20d1b9992d04f7
1 require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
3 describe String do
4   before do
5     @string = %{
6       0123456789
7       012345
8       01234567
9       0123
10     }.tabto(0).strip
11   end
12   
13   it "can translate indices to column numbers" do
14     @string.column_of(0).should == 1
15     @string.column_of(5).should == 6
16     @string.column_of(10).should == 11
17     @string.column_of(11).should == 1
18     @string.column_of(17).should == 7
19     @string.column_of(18).should == 1
20     @string.column_of(24).should == 7
21   end
22   
23   it "can translate indices to line numbers" do
24     @string.line_of(0).should == 1
25     @string.line_of(5).should == 1
26     @string.line_of(10).should == 1
27     @string.line_of(11).should == 2
28     @string.line_of(17).should == 2
29     @string.line_of(18).should == 3
30     @string.line_of(24).should == 3
31   end
32 end