我正在处理以下Ruby Koan:
class Dog7
attr_reader :name
def initialize(initial_name)
@name = initial_name
end
def get_self
self
end
def to_s
__
end
def inspect
"<Dog named '#{name}'>"
end
end
def test_inside_a_method_self_refers_to_the_containing_object
fido = Dog7.new("Fido")
fidos_self = fido.get_self
assert_equal "<Dog named 'Fido'>", fidos_self
end
def test_to_s_provides_a_string_version_of_the_object
fido = Dog7.new("Fido")
assert_equal __, fido.to_s
end
第一个assert_equal的前半部分是我想填入的内容。这段代码会报错:
<"<Dog named 'Fido'>"> expected but was <<Dog named 'Fido'>>.
问题是,我不知道如何匹配返回值。看起来这是一个字符串字面值返回值,但我不知道如何在不使用引号和/或反斜杠的情况下表示它。无论我尝试什么都不起作用。
能帮忙吗?