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

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 :/