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

testing the profiles controller

Hi! when i test my profiles controller this is the failure I get:

test_only_shows_the_correct_user's_statuses(ProfilesControllerTest) [test/functional/profiles_controller_test.rb:25]: <#<User id: 890002738, first_name: "Brian", last_name: "Goldstein", profile_name : "briangoldstein", email: "kapp.gold@gmail.com", encrypted_password: "", reset_ password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign _in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: "2013-11-07 04:22:47", updated_at: "2013 -11-07 04:22:47">> expected but was <nil>.

the pertinent lines in my controller test are:

  test "only shows the correct user's statuses" do 
    get :show, id: users(:brian).profile_name
    assigns(:statuses).each do  |status|
      assert_equal users(:brian), status.user
    end

1 Answer

Scoping issue -

If you run into this problem, the scoping solution that Jason shows in the scoping video corrects it and the test runs without fail