Module: String::Etest

Defined in:
lib/vex/boot/string.rb

Instance Method Summary collapse

Instance Method Details

#test_constantizeObject


51
52
53
54
55
56
57
58
59
# File 'lib/vex/boot/string.rb', line 51

def test_constantize
  assert_equal String, "String".constantize
  assert_raise(NameError) {
    "I::Dont::Know::This".constantize
  }
  assert_raise(ArgumentError) {
    "".constantize
  }
end

#test_ends_withObject


39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vex/boot/string.rb', line 39

def test_ends_with
  assert "abcde".ends_with?("")
  assert "abcde".ends_with?("e")
  assert "abcde".ends_with?("de")
  assert "abcde".ends_with?("cde")
  assert "abcde".ends_with?("bcde")
  assert "abcde".ends_with?("abcde")

  assert !("abcde".ends_with?("abcdef"))
  assert !("abcde".ends_with?("xy"))
end

#test_starts_withObject


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vex/boot/string.rb', line 27

def test_starts_with
  assert "abcde".starts_with?("")
  assert "abcde".starts_with?("a")
  assert "abcde".starts_with?("ab")
  assert "abcde".starts_with?("abc")
  assert "abcde".starts_with?("abcd")
  assert "abcde".starts_with?("abcde")

  assert !("abcde".starts_with?("abcdef"))
  assert !("abcde".starts_with?("xy"))
end