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

Brad Halstead
Brad Halstead
5,662 Points

Test factories user_friendship_controller_test failures

After spending countless hours looking through my code for typo's I have not been able to get past these failures... everything passed fine before adding the factorygirl stuff. I have re-watched the previous 6 videos trying to find where it went wrong. Help please. I'll start with adding the failure message from running the test..

$ ruby -I test test/functional/user_friendships_controller_test.rb Run options:

Running tests:

FFFFF.............

Finished tests in 0.927053s, 19.4164 tests/s, 24.8098 assertions/s.

1) Failure: test: #create when logged in with a valid friend_id should assign a friend objec t. (UserFriendshipsControllerTest) [test/functional/user_friendships_controller_ test.rb:104]: Failed assertion, no message given.

2) Failure: test: #create when logged in with a valid friend_id should assign a user_friends hip object. (UserFriendshipsControllerTest) [test/functional/user_friendships_co ntroller_test.rb:109]: Failed assertion, no message given.

3) Failure: test: #create when logged in with a valid friend_id should create a friendship. (UserFriendshipsControllerTest) [test/functional/user_friendships_controller_tes t.rb:115]: Failed assertion, no message given.

4) Failure: test: #create when logged in with a valid friend_id should redirect to the profi le page of the friend. (UserFriendshipsControllerTest) [test/functional/user_fri endships_controller_test.rb:120]: Expected response to be a redirect to http://test.host/pamsue05 but was a redi rect to http://test.host/

5) Failure: test: #create when logged in with a valid friend_id should set the flash success message. (UserFriendshipsControllerTest) [test/functional/user_friendships_cont roller_test.rb:124]: Failed assertion, no message given.

18 tests, 23 assertions, 5 failures, 0 errors, 0 skips

4 Answers

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Brad Halstead can you push your code up to GitHub and send me a link so I can take a look at it?

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Brad,

One line 100 of test/function/user_friendships_controller_rest.rb, change it to read:

post :create, user_friendship: { friend_id: users(:pam).profile_name }

And everything should work. If you check out the create action of the user friendships controller, it is looking for the friend_id inside of the user_friendship param which is why it was failing. Hope that helps!

Brad Halstead
Brad Halstead
5,662 Points

Yes Jason, that worked!! Thanks for your assistance, now I'm back on track, much appreciated!!