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 Build a Simple Ruby on Rails Application Building the Profile Page Testing the Profile Name

Nelly Nelly
Nelly Nelly
7,134 Points

Test "profile name without spaces" fail...

Hi there :)

According to the answer in the previous question, I put the suggested code

validates :profile_name,  presence: true,
                                            uniqueness: true,
                                            format: {

                                                            with: /\A[a-zA-Z0-9_-]+\z/,
                                                            message: "Must be formatted correctly."

                                                        }

So the test : correcty formated profile name pass, but the name without space fails now ... I don't know how to set it... don't understand much about regular expressions...

Hope you could me guys, Steve Hunter maybe ?

Cheers :)

Ilya Dolgirev
Ilya Dolgirev
35,375 Points

RegExp looks good. Could you provide your test spec file?

Nelly Nelly
Nelly Nelly
7,134 Points

yes sure :smile:

  test "A user should have a profile name without spaces " do
    user = User.new(first_name: 'Jason', last_name:'Seifer', email: 'jason2@tree.com')
    user.password = user.password_confirmation = '123456'

    user.profile_name ="My profile name with spaces"

    assert !user.save
    assert !user.errors[:profile_name].empty?
    assert user.errors[:profile_name].include?("Must be formated correctly.")
  end

2 Answers

Ilya Dolgirev
Ilya Dolgirev
35,375 Points

Hmm, you have misspelled word in assertion :)

"Must be formated correctly." not equal to "Must be formatted correctly."

Nelly Nelly
Nelly Nelly
7,134 Points

awww.... stupid me :( thank you

Are you fixed now?

Steve.

Nelly Nelly
Nelly Nelly
7,134 Points

Yes thanks guys !! It was a real stupid mistake sorry for bothering you :(