require File.expand_path(File.dirname(__FILE__) + '/neo') class AboutStrings < Neo::Koan def test_double_quoted_strings_are_strings string = "Hello, World" assert_equal true, string.is_a?(String) end def test_single_quoted_strings_are_also_strings string = 'Goodbye, World' assert_equal true, string.is_a?(String) end def test_use_single_quotes_to_create_string_with_double_quotes string = 'He said, "Go Away."' assert_equal 'He said, "Go Away."', string end def test_use_double_quotes_to_create_strings_with_single_quotes string = "Don't" assert_equal "Don't", string end def test_use_backslash_for_those_hard_cases a = "He said, \"Don't\"" b = 'He said, "Don\'t"' assert_equal true, a == b end def test_use_flexible_quoting_to_handle_really_hard_cases a = %(flexible quotes can handle both ' and " characters) b = %!flexible quotes can handle both ' and " characters! c = %{flexible quotes can handle both ' and " characters} assert_equal true, a == b assert_equal true, a == c end def test_flexible_quotes_can_handle_multiple_lines long_string = %{ It was the best of times, It was the worst of times. } assert_equal 54, long_string.length assert_equal 3, long_string.lines.count assert_equal "\n", long_string[0,1] end def test_here_documents_can_also_handle_multiple_lines long_string = <