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 trialGlenn Foltz
Courses Plus Student 8,178 PointsTreebook Validating Format Error
my users_test.rb code
test "a user should have a profile name without spaces" do
user = User.new
user.profile_name = "A Profile Name With Spaces"
assert !user.save
assert !user.errors[:profile_name].empty?
assert users.errors[:profile_name].include?("must be formatted correctly.")
end
my users.rb code
validates :profile_name, format: {
with: /\A[a-zA-Z\-\_]+\Z/,
message: "must be formatted correctly."
}
This is the error message i get in terminal when I run ruby -Itest test/unit/user_test.rb
1) Error:
test_a_user_should_have_a_profile_name_without_spaces(UserTest):
NoMethodError: undefined method ` errors ' for []:Array test/unit/user_test.rb:35:in `block in <class:UserTest>'
5 tests, 10 assertions, 0 failures, 1 errors, 0 skips
1 Answer
Glenn Foltz
Courses Plus Student 8,178 PointsNevermind... just had to post it to find my typo.
Glenn Foltz
Courses Plus Student 8,178 PointsGlenn Foltz
Courses Plus Student 8,178 Pointsmore than one, actually.