Sha256: 6c2647b49b32e56ea2ac6d0cc14c930d33de6cb29a53727ab629dbb35bb13270
Contents?: true
Size: 1.6 KB
Versions: 14
Compression:
Stored size: 1.6 KB
Contents
describe "String" do describe "indent" do it "should not indent strings that only contain newlines (edge cases)" do ['', "\n", "\n" * 7].each do |str| str.indent!(8).should.be.nil str.indent(8).should == str str.indent(1, "\t").should == str end end it "should indent by default with spaces if the existing indentation uses them" do "foo\n bar".indent(4).should == " foo\n bar" end it "should indent by default with tabs if the existing indentation uses them" do "foo\n\t\bar".indent(1).should == "\tfoo\n\t\t\bar" end it "should indent by default with spaces as a fallback if there is no indentation" do "foo\nbar\nbaz".indent(3).should == " foo\n bar\n baz" end # Nothing is said about existing indentation that mixes spaces and tabs, so # there is nothing to test. it "should use the indent char if passed" do <<ACTUAL.indent(4, '.').should == <<EXPECTED def some_method(x, y) some_code end ACTUAL .... def some_method(x, y) .... some_code .... end EXPECTED <<ACTUAL.indent(2, ' ').should == <<EXPECTED def some_method(x, y) some_code end ACTUAL def some_method(x, y) some_code end EXPECTED end it "should not indent blank lines by default" do "foo\n\nbar".indent(1).should == " foo\n\n bar" end it "should indent blank lines if told so" do "foo\n\nbar".indent(1, nil, true).should == " foo\n \n bar" end end end
Version data entries
14 entries across 14 versions & 2 rubygems