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

General Discussion

Profile name with spaces test continuing to fail

I'm not sure what I'm missing here as my code looks the same as the video but my profile name with spaces test is still failing.

My test:

    test "a user should have a profile name without spaces" do
        user = User.new
        user.profile_name = "My Profile With Spaces"

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

user.rb validation:

  validates :profile_name, presence: true,
                           uniqueness: true,
                           format: {
                            with: /a-zA-Z0-9_-/,
                            message: 'Must be formatted corrrectly.'
                           }

The error is indicating there is a failed assertion on line 40 of user_test.rb which is the following line:

assert user.errors[:profile_name].include?("Must be formatted correctly.")

1 Answer

I guess posting the question allowed me to see the light.

I had the word "correctly" misspelled in my user.rb validation. Fixing the misspelling solved the problem.