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.

Ruby

Khemraj Thapa
Khemraj Thapa
8,885 Points

Error while testing friendhships :Solved

Hi, I have followed everything shown on the video but still getting 3 errors like below:

test: UserFriendship should belong to friend. (UserFriendshipTest): ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

Error: test: UserFriendship should belong to user. (UserFriendshipTest): ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

Error: test_that_creating_a_friendship_works_without_raising_an_exception(UserFriendshipTest): ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

What am i doing wrong? Thanks in advance

2 Answers

Tomasz Foster
Tomasz Foster
19,442 Points

The test you wrote fails because the user friendship doesn't belong to a friend, which is what you're testing for. Therefore, make sure you have a belongs_to association in your user friendship model for the :user.

Without seeing the rest of the code it's hard to see what's wrong, but I would suggest checking your App / models / user_friendship.rb file.

Good luck!

Khemraj Thapa
Khemraj Thapa
8,885 Points

Hi Tomasz, thanks for the reply but I have done everything you have said but still not working. On all the errors it says ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

so I wonder what wrong with that, I tried to do it again and again watching videos multiple times and doing same things jason is doing on the video but still, I get the errors.

Khemraj Thapa
Khemraj Thapa
8,885 Points

tried to do it all over again for the 3rd time and it working now :/