Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialYuichi Hagio
11,367 Points[Help] Ruby on Rails - Testing the Profile Name
I cannot pass the test. Could you help me pass the test?
I still get this error:
1) Failure: test_An_user_should_have_a_correctly_formatted_profile_name(UserTest) [test/unit/user_test.rb:42]: Failed assertion, no message given.
6 tests, 12 assertions, 1 failures, 0 errors, 0 skips
I modified the code as Jason did:
---------- user.rb ----------
validates :profile_name,
presence: true,
uniqueness: true,
format: {
with: /^[a-zA-Z0-9_-]+$/,
message: 'must be formatted correctly.'
}
---------- user_test.rb ----------
test "An user should have a correctly formatted profile name" do
user = User.new(first_name: 'John', last_name: 'Smith', email: 'johnsmith@example.com')
user.password = user.password_confirmation = 'johnsmith'
user.profile_name = 'johnsmith_1'
assert user.valid?
end
17 Answers
Jason Seifer
Treehouse Guest TeacherIf anyone is still having problems please drop us a line to help@teamtreehouse.com with your code attached. Thanks!
Yuichi Hagio
11,367 PointsThe problem in this example is that user object isn't validating because the email address has already been taken. So change the email address in the test, it worked for me!
Ryan Carson
23,287 PointsHi Yuichi
Thanks for posting here. We'll get you an answer as soon as possible.
Thanks for being a Treehouse Student!
Ryan
Founder/CEO, Treehouse
Jason Seifer
Treehouse Guest TeacherHi Yuichi,
Can you zip up your treebook project directory and email it to help@teamtreehouse.com and I'll take a look? Thanks!
jmt
13,877 PointsI had this same issue and changing just the email address did not work. I had to use a different user.profile_name as well.
Ryan Ebbers
3,746 PointsI went with Yuichi's suggestion by changing the ( profile_name: , email: ) to something unique, and it worked for me.
Yuichi Hagio
11,367 PointsThank you Ryan,
Please note that it was working fine until this chapter, and I'm using Mac OS X 10.8.2, and Rails 3.2.8.
I also noticed that the code on Testing the Profile Name page is different from the one in the lecture video. Neither of them did not work.
The code on the Testing the Profile Name page (https://teamtreehouse.com/library/programming-2/build-a-simple-version-of-facebook/building-the-profile-page/testing-the-profile-name):
validates :profile_name, presence: true,
uniqueness: true,
format: {
with: /[a-ZA-Z0-9_-]+/,
}
The code in the lecture video:
validates :profile_name, presence: true,
uniqueness: true,
format: {
with: /^[a-zA-Z0-9_-]+$/,
}
Allan Evans
9,501 PointsGot the same problem, let me know if you find a solution.
Trevor Williams
5,859 PointsI'm running into the same problem, have any of you guys found the solution?
thanks
Allan Evans
9,501 PointsThanks for finding that, it's always the little things.
Trevor Williams
5,859 PointsThanks for the help!
Moritz Iso
1,269 PointsThanks for the help too! It works also for me by changing the user information.
BPO Outfit
Courses Plus Student 3,780 Pointsi am having this problem as well.
Alexander Hoffmann
1,402 PointsMe too..
Chris .
1,133 PointsAny luck finding a solution to this issue?
Rodrigo Giust
5,179 PointsI'm also having the same issue, and changing the e-mail didn't work for me.
Ivan Bechev
851 PointsChanging the email in the test worked for me too. Thanks !