Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
708 views
in Technique[技术] by (71.8m points)

unit testing - Rails strange error => IndexError: string not matched

I've got a very strange message error. I think it's not coming from Ruby but from the unix system.

So, I have the following test file:

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

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

So, nothing coming from YAML files in the Fixtures directory.

When I run the test above with the command:

$ ruby ./test/unit/cat_test.rb

I get the very strange result:

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

I can't find the meaning of the error

IndexError: string not matched

But the most strange is that yesterday, It worked!

Thank you very much for your help.

Regards

(I'm working under Ubuntu 9.04)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This happens, for example, when you try to access a string variable as a Hash by mistake.

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

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

Additional Information


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...