I am currently on Chapter 6 on RoR tutorials (Hartl's) figuring out modeling users. And, I ran into a problem when I run the rake test - I constantly get an error message shown below:
/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)
So, I have taken a look at the user_Controller_test.rb file, and tried fidgeting here, but no luck. My user_controller_test.rb is shown below.
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
test "should get new" do
get :new
assert_response :success
end
end
I have tried deleting the four lines of code shown below
test "should get new" do
get :new
assert_response :success
end
and ran the rake test, and the error message now appears as below:
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
And now I am stuck.. I am a beginner in RoR, and I feel helpless... I don't know how to figure out these error codes.
I will highly appreciate your expert advice please.
Thank you.