Module: StringExt::Etest
- Defined in:
- lib/vex/base/string/string_ext.rb
Instance Method Summary collapse
- #test_constantize ⇒ Object
- #test_downcase ⇒ Object
-
#test_truncate ⇒ Object
truncate :length => 30, :omission => “…”.
- #test_truncate! ⇒ Object
- #test_unhtml ⇒ Object
- #test_uri ⇒ Object
- #test_word_wrap ⇒ Object
Instance Method Details
#test_constantize ⇒ Object
149 150 151 152 |
# File 'lib/vex/base/string/string_ext.rb', line 149 def test_constantize assert_equal String, "String".constantize? assert_equal nil, "I::Dont::Know::This".constantize? end |
#test_downcase ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/vex/base/string/string_ext.rb', line 154 def test_downcase assert_equal true, "expected".downcase? assert_equal false, "Expected".downcase? assert_equal false, "EXPECTED".downcase? assert_equal false, "expected".upcase? assert_equal false, "Expected".upcase? assert_equal true, "EXPECTED".upcase? assert_equal true, "".upcase? assert_equal true, "".downcase? end |
#test_truncate ⇒ Object
truncate :length => 30, :omission => “…”
119 120 121 122 123 124 125 |
# File 'lib/vex/base/string/string_ext.rb', line 119 def test_truncate assert_equal("", "".truncate) assert_equal("123456", "123456".truncate) assert_equal("123…", "1234567".truncate(:length => 6)) assert_equal("123…", "1234567".truncate(6)) assert_equal("12345~", "1234567".truncate(6, "~")) end |
#test_truncate! ⇒ Object
127 128 129 130 131 132 133 134 135 |
# File 'lib/vex/base/string/string_ext.rb', line 127 def test_truncate! s = "1234567" assert_equal "123…", s.truncate(6) assert_equal "1234567", s assert_equal "123…", s.truncate!(6) assert_equal "123…", s end |
#test_unhtml ⇒ Object
111 112 113 114 115 116 |
# File 'lib/vex/base/string/string_ext.rb', line 111 def test_unhtml assert_equal("", "".unhtml) assert_equal("hjghjg", "<p>hjghjg</p>".unhtml) assert_equal("ä", "ä".unhtml) assert_equal("ä", "ä".unhtml) end |
#test_uri ⇒ Object
143 144 145 146 147 |
# File 'lib/vex/base/string/string_ext.rb', line 143 def test_uri assert_equal true, "http://".uri? assert_equal false, "//".uri? assert_equal false, "c:\\x\\y".uri? end |
#test_word_wrap ⇒ Object
137 138 139 140 141 |
# File 'lib/vex/base/string/string_ext.rb', line 137 def test_word_wrap assert_equal "abcdef\nghijkl", "abcdef ghijkl".word_wrap(8) assert_equal "abc def\nghijkl", "abc def ghijkl".word_wrap(8) assert_equal "abcdefghijkl", "abcdefghijkl".word_wrap(8) end |