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 trialNelly Nelly
7,134 PointsTest "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 :)
Nelly Nelly
7,134 Pointsyes sure
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
35,375 PointsHmm, you have misspelled word in assertion :)
"Must be formated correctly."
not equal to "Must be formatted correctly."
Nelly Nelly
7,134 Pointsawww.... stupid me :( thank you
Steve Hunter
57,712 PointsAre you fixed now?
Steve.
Nelly Nelly
7,134 PointsYes thanks guys !! It was a real stupid mistake sorry for bothering you :(
Ilya Dolgirev
35,375 PointsIlya Dolgirev
35,375 PointsRegExp looks good. Could you provide your test spec file?