Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Glenn Foltz
Glenn Foltz
Courses Plus Student 8,178 Points

Treebook 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.")

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:
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
Glenn Foltz
Courses Plus Student 8,178 Points

Nevermind... just had to post it to find my typo.