私は現在 RoR チュートリアル (Hartl's) の第 6 章でモデリング ユーザーを理解しています。そして、レーキ テストを実行すると問題が発生しました。次のようなエラー メッセージが常に表示されます。
/u$ bundle exec rake test
rake aborted!
test_should_get_new is already defined in UsersControllerTest
/Users/joebcvan/.rvm/gems/ruby-2.2.0@global/gems/activesupport-
4.2.0/lib/active_support/testing/declarative.rb:14:in `test'
.
.
.
/Users/joebcvan/.rvm/gems/ruby-2.2.0@global/gems/railties-
4.2.0/lib/rails/test_unit/sub_test_task.rb:20:in `invoke_rake_task'
/Users/joebcvan/.rvm/gems/ruby-2.2.0@global/gems/railties-
4.2.0/lib/rails/test_unit/testing.rake:8:in `block in <top (required)>'
Tasks: TOP => test:run
(See full trace by running task with --trace)
それで、私は user_Controller_test.rb ファイルを見て、ここでそわそわしようとしましたが、うまくいきませんでした。私の user_controller_test.rb を以下に示します。
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
test "should get new" do
get :new
assert_response :success
end
end
以下に示す4行のコードを削除しようとしました
test "should get new" do
get :new
assert_response :success
end
レーキ テストを実行すると、次のようなエラー メッセージが表示されます。
1) Error:
SiteLayoutTest#test_should_get_home:
SyntaxError: /Users/joebcvan/workspace/sample_app/app/models/user.rb:5: syntax
error, unexpected ':', expecting keyword_end
format: { with: VALID_EMAIL_REGEX}
^
Error:
SiteLayoutTest#test_should_get_home:
NoMethodError: undefined method `each' for nil:NilClass
2) Error:
SiteLayoutTest#test_should_get_help:
SyntaxError: /Users/joebcvan/workspace/sample_app/app/models/user.rb:5: syntax
error, unexpected ':', expecting keyword_end
format: { with: VALID_EMAIL_REGEX}
^
Error:
SiteLayoutTest#test_should_get_help:
NoMethodError: undefined method `each' for nil:NilClass
.
.
.
.
12) Error:
UserTest#test_name_should_not_be_too_long:
SyntaxError: /Users/joebcvan/workspace/sample_app/app/models/user.rb:5: syntax
error, unexpected ':', expecting keyword_end
format: { with: VALID_EMAIL_REGEX}
^
13) Error:
UserTest#test_should_be_valid:
SyntaxError: /Users/joebcvan/workspace/sample_app/app/models/user.rb:5: syntax
error, unexpected ':', expecting keyword_end
format: { with: VALID_EMAIL_REGEX}
^
13 runs, 0 assertions, 0 failures, 13 errors, 0 skips
そして今、私は立ち往生しています..私はRoRの初心者であり、無力感を感じています...これらのエラーコードを理解する方法がわかりません.
専門家のアドバイスをいただければ幸いです。
ありがとうございました。