gpt4 book ai didi

ruby-on-rails - Rails 奇怪的错误 => IndexError : string not matched

转载 作者:行者123 更新时间:2023-12-03 11:33:49 30 4
gpt4 key购买 nike

我有一个非常奇怪的消息错误。我认为它不是来自 Ruby 而是来自 unix 系统。

所以,我有以下测试文件:

require File.dirname(__FILE__) + '/../test_helper' 

class CatTest < ActiveSupport::TestCase
def test_truth
assert true
end
end

因此,Fixtures 目录中的 YAML 文件没有任何内容。

当我使用以下命令运行上面的测试时:
$ ruby ./test/unit/cat_test.rb

我得到了非常奇怪的结果:
Loaded suite ./test/unit/cat_test
Started
E
Finished in 0.011252 seconds.

1) Error:
test_truth(CatTest):
IndexError: string not matched


1 tests, 0 assertions, 0 failures, 1 errors

我找不到错误的含义
IndexError: string not matched

但最奇怪的是,昨天,它奏效了!

非常感谢您的帮助。

问候

(我在 Ubuntu 9.04 下工作)

最佳答案

例如,当您错误地尝试将字符串变量作为 Hash 访问时,就会发生这种情况。

s = "a string"
s["position"] = "an other string"

IndexError: string not matched
from (irb):5:in `[]='
from (irb):5

Additional Information

关于ruby-on-rails - Rails 奇怪的错误 => IndexError : string not matched,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2072283/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com