2012-01-18 11 views
0

私はルビーが初めてです。私は私のwatirスクリプトのためのヘルパーメソッドファイルを作成しました。helper_methodファイルを開くときに以下のエラー[無効なブレーク(SyntaxError)]が表示される

require "C:/Sites/common/helper_methods" 

をし、このエラーメッセージがスローされます:私は、スクリプトを実行しようとすると、それは、この行を打つ

C:/Sites/common/helper_methods.rb: C:/Sites/common/helper_methods.rb:1387: Invalid break (SyntaxError) 

はので、私はエラーが何を意味するのかわかりません。

私は答えを探しましたが、メッセージを理解するのに役立つものは見つかりませんでした。

ご協力いただければ幸いです。

ジョー

こんにちはポール、

ここ

が1387 1387

後の方法に問題

かもしれません

#Write Subject Lines to file 
def add_subject_line_to_file(s) 

project_path = Dir.pwd 

fileNamePath = File.join(project_path,'data_files','multi_add_discussion_files','multi_add_discussion_headers.txt') 

#Writing to new file 
open(fileNamePath,'a+'){ |f| 
    f << "#{s}\n" 
} 
end 

前方法であり、

#The following method will validate text at on the page not in a specific location 
def text_validation(rt) 

    #Validate comment displays 
    if @browser.text.include? rt 

     #Response 
     response = "PASS!!! The following user comment was found [ #{rt} ]." 
     write_to_file(response) 

    else 

     #Response 
     response = "FAIL!!! The following user comment was NOT found [ #{rt} ]." 
     write_to_file(response) 

    end #End of Validate comment displays 

end 

答えて

0

ライン:

C:/Sites/common/helper_methods.rb: 
C:/Sites/common/helper_methods.rb:1387: 
Invalid break (SyntaxError) 

がhelper_methods.rbのライン1387上(にSyntaxErrorを)解析エラーがあります意味(... helper_methods.rb:1387)。

エラーはずっと早く発生する可能性がありますが、通訳者は行1387にしか気付くことができません。行1387の周りに行を投稿すると、さらに診断するのに役立ちます。

1378は、1つのファイルに多くの行があります。これらのメソッドを関連するハンクに分割し、必要な部分のみを含めることを考えたいと思うかもしれません。これを行うことで、必要なことができない1つのファイルにエラーがあることがわかっている場合、5または6が必要な場合にエラーを見つけるのに役立ちます。また、問題を引き起こすものを見つけるまで、helper_methodsのメソッドをコメントアウトすることもできます。

関連する問題