hashes, and strings
This commit is contained in:
@@ -94,11 +94,11 @@ class AboutHashes < Neo::Koan
|
|||||||
hash[:one] << "uno"
|
hash[:one] << "uno"
|
||||||
hash[:two] << "dos"
|
hash[:two] << "dos"
|
||||||
|
|
||||||
assert_equal __, hash[:one]
|
assert_equal ["uno", "dos"], hash[:one]
|
||||||
assert_equal __, hash[:two]
|
assert_equal ["uno", "dos"], hash[:two]
|
||||||
assert_equal __, hash[:three]
|
assert_equal ["uno", "dos"], hash[:three]
|
||||||
|
|
||||||
assert_equal __, hash[:one].object_id == hash[:two].object_id
|
assert_equal true, hash[:one].object_id == hash[:two].object_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_default_value_with_block
|
def test_default_value_with_block
|
||||||
@@ -107,8 +107,8 @@ class AboutHashes < Neo::Koan
|
|||||||
hash[:one] << "uno"
|
hash[:one] << "uno"
|
||||||
hash[:two] << "dos"
|
hash[:two] << "dos"
|
||||||
|
|
||||||
assert_equal __, hash[:one]
|
assert_equal ["uno"], hash[:one]
|
||||||
assert_equal __, hash[:two]
|
assert_equal ["dos"], hash[:two]
|
||||||
assert_equal __, hash[:three]
|
assert_equal [], hash[:three]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,36 +3,36 @@ require File.expand_path(File.dirname(__FILE__) + '/neo')
|
|||||||
class AboutStrings < Neo::Koan
|
class AboutStrings < Neo::Koan
|
||||||
def test_double_quoted_strings_are_strings
|
def test_double_quoted_strings_are_strings
|
||||||
string = "Hello, World"
|
string = "Hello, World"
|
||||||
assert_equal __, string.is_a?(String)
|
assert_equal true, string.is_a?(String)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_single_quoted_strings_are_also_strings
|
def test_single_quoted_strings_are_also_strings
|
||||||
string = 'Goodbye, World'
|
string = 'Goodbye, World'
|
||||||
assert_equal __, string.is_a?(String)
|
assert_equal true, string.is_a?(String)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_single_quotes_to_create_string_with_double_quotes
|
def test_use_single_quotes_to_create_string_with_double_quotes
|
||||||
string = 'He said, "Go Away."'
|
string = 'He said, "Go Away."'
|
||||||
assert_equal __, string
|
assert_equal 'He said, "Go Away."', string
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_double_quotes_to_create_strings_with_single_quotes
|
def test_use_double_quotes_to_create_strings_with_single_quotes
|
||||||
string = "Don't"
|
string = "Don't"
|
||||||
assert_equal __, string
|
assert_equal "Don't", string
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_backslash_for_those_hard_cases
|
def test_use_backslash_for_those_hard_cases
|
||||||
a = "He said, \"Don't\""
|
a = "He said, \"Don't\""
|
||||||
b = 'He said, "Don\'t"'
|
b = 'He said, "Don\'t"'
|
||||||
assert_equal __, a == b
|
assert_equal true, a == b
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_flexible_quoting_to_handle_really_hard_cases
|
def test_use_flexible_quoting_to_handle_really_hard_cases
|
||||||
a = %(flexible quotes can handle both ' and " characters)
|
a = %(flexible quotes can handle both ' and " characters)
|
||||||
b = %!flexible quotes can handle both ' and " characters!
|
b = %!flexible quotes can handle both ' and " characters!
|
||||||
c = %{flexible quotes can handle both ' and " characters}
|
c = %{flexible quotes can handle both ' and " characters}
|
||||||
assert_equal __, a == b
|
assert_equal true, a == b
|
||||||
assert_equal __, a == c
|
assert_equal true, a == c
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_flexible_quotes_can_handle_multiple_lines
|
def test_flexible_quotes_can_handle_multiple_lines
|
||||||
@@ -40,9 +40,9 @@ class AboutStrings < Neo::Koan
|
|||||||
It was the best of times,
|
It was the best of times,
|
||||||
It was the worst of times.
|
It was the worst of times.
|
||||||
}
|
}
|
||||||
assert_equal __, long_string.length
|
assert_equal 54, long_string.length
|
||||||
assert_equal __, long_string.lines.count
|
assert_equal 3, long_string.lines.count
|
||||||
assert_equal __, long_string[0,1]
|
assert_equal "\n", long_string[0,1]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_here_documents_can_also_handle_multiple_lines
|
def test_here_documents_can_also_handle_multiple_lines
|
||||||
@@ -50,9 +50,9 @@ It was the worst of times.
|
|||||||
It was the best of times,
|
It was the best of times,
|
||||||
It was the worst of times.
|
It was the worst of times.
|
||||||
EOS
|
EOS
|
||||||
assert_equal __, long_string.length
|
assert_equal 53, long_string.length
|
||||||
assert_equal __, long_string.lines.count
|
assert_equal 2, long_string.lines.count
|
||||||
assert_equal __, long_string[0,1]
|
assert_equal "I", long_string[0,1]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_plus_will_concatenate_two_strings
|
def test_plus_will_concatenate_two_strings
|
||||||
|
|||||||
Reference in New Issue
Block a user