brew/Library/Homebrew/test/test_string.rb
Baptiste Fontaine a6d2723ef5 more core unit tests
Closes Homebrew/homebrew#47182.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
2015-12-20 12:11:40 +01:00

41 lines
784 B
Ruby

require "testing_env"
require "extend/string"
class StringTest < Homebrew::TestCase
def test_undent
undented = <<-EOS.undent
hi
....my friend over
there
EOS
assert_equal "hi\n....my friend over\nthere\n", undented
end
def test_undent_not_indented
undented = <<-EOS.undent
hi
I'm not indented
EOS
assert_equal "hi\nI'm not indented\n", undented
end
def test_undent_nested
nest = <<-EOS.undent
goodbye
EOS
undented = <<-EOS.undent
hello
#{nest}
EOS
assert_equal "hello\ngoodbye\n\n", undented
end
def test_inreplace_sub_failure
s = "foobar".extend StringInreplaceExtension
s.sub! "not here", "test"
assert_equal [%(expected replacement of "not here" with "test")], s.errors
end
end