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

Fixture Video - Failing on assert !user.save

Keep getting a failure on a specific test where I am testing the Unique Profile Name. Keep getting the following error:

UserTest#test_a_user_should_have_a_unique_profile_name [test/models/user_test.rb:33]:

Failed assertion, no message given.

My test looks like this: test "a user should have a unique profile name" do user = User.new user.profile_name = "jordansaxe" user.email = "email here" user.first_name = "Jordan" user.last_name = "Saxe" user.password = "password" user.password_confirmation = "password" assert !user.save puts user.errors.inspect assert !user.errors[:profile_name].empty?

The test says its failing on "assert !user.save".

4 Answers

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Jordan Saxe do you have a users fixture with the "jordansaxe" profile name already? If not, that could be the issue.

Hi Jason,

I do. My users.yml has: jordan: first_name: "Jordan" last_name: "Saxe" email: "email here" profile_name: "jordansaxe"

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

For the moment, try taking out the assert !user.save and change it to "user.save". Then can you paste the errors that it outputs from the next line?

I am getting the following:

6) Error: UserTest#test_a_user_should_have_a_unique_profile_name: NoMethodError: undefined method `env' for nil:NilClass

In fact, I am getting that error for all of the tests (first name, last name, profile name, formatted profile name, profile name without spaces and unique profile name).

I am using Ruby 2 and Rails 4