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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
require 'spec_helper'
describe 'core_extensions/string' do
describe "to_crlf" do
it "should change a single LF to CRLF" do
"\n".to_crlf.should eq "\r\n"
end
it "should change multiple LF to CRLF" do
"\n\n".to_crlf.should eq "\r\n\r\n"
end
it "should change a single CR to CRLF" do
"\r".to_crlf.should eq "\r\n"
end
it "should not change CRLF" do
"\r\n".to_crlf.should eq "\r\n"
end
it "should not change multiple CRLF" do
"\r\n\r\n".to_crlf.should eq "\r\n\r\n"
end
it "should handle a mix" do
"\r \n\r\n".to_crlf.should eq "\r\n \r\n\r\n"
end
end
describe "to_lf" do
it "should change a single CR to LF" do
"\r".to_lf.should eq "\n"
end
it "should change multiple LF to CRLF" do
"\r\r".to_lf.should eq "\n\n"
end
it "should change a single CRLF to LF" do
"\r\n".to_lf.should eq "\n"
end
it "should change multiple CR to LF" do
"\r\n\r\n".to_lf.should eq "\n\n"
end
it "should not change LF" do
"\n".to_lf.should eq "\n"
end
it "should not change multiple CRLF" do
"\n\n".to_lf.should eq "\n\n"
end
it "should handle a mix" do
"\r \n\r\n".to_lf.should eq "\n \n\n"
end
end
describe 'constantize' do
it 'should converts string to constant' do
"Kernel".constantize.should eq Kernel
end
end
end
|