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 trial

Ruby

[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
STAFF
Jason Seifer
Treehouse Guest Teacher

If anyone is still having problems please drop us a line to help@teamtreehouse.com with your code attached. Thanks!

The 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!

Hi 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
STAFF
Jason Seifer
Treehouse Guest Teacher

Hi Yuichi,

Can you zip up your treebook project directory and email it to help@teamtreehouse.com and I'll take a look? Thanks!

jmt
jmt
13,877 Points

I had this same issue and changing just the email address did not work. I had to use a different user.profile_name as well.

I went with Yuichi's suggestion by changing the ( profile_name: , email: ) to something unique, and it worked for me.

Thank 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_-]+$/,
                       }

Got the same problem, let me know if you find a solution.

Trevor Williams
Trevor Williams
5,859 Points

I'm running into the same problem, have any of you guys found the solution?

thanks

Thanks for finding that, it's always the little things.

Moritz Iso
Moritz Iso
1,269 Points

Thanks for the help too! It works also for me by changing the user information.

i am having this problem as well.

Chris .
Chris .
1,133 Points

Any luck finding a solution to this issue?

Rodrigo Giust
Rodrigo Giust
5,179 Points

I'm also having the same issue, and changing the e-mail didn't work for me.

Changing the email in the test worked for me too. Thanks !