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
primos
6,465 PointsTest Factories - multiple errors after running rake
Hi! I finished the Test Factories video and should get no errors or failures but instead, after running rake in terminal, I get multiple of them. First 1) Failure:
test_a_user_can_have_a_correctly_formatted_profile_name(UserTest) [/home/jure/projects/treebook/test/unit/user_test.rb:51]:
Failed assertion, no message given.
Second 1) Error:
test: #index when loggeed in should assign user_friendships. (UserFriendshipsControllerTest):
ArgumentError: Factory not registered: accepted_user_friendship
/home/jure/.rvm/gems/ruby-1.9.3-p194/gems/factory_girl-4.3.0/lib/factory_girl/registry.rb:24:in `find'
Third 2) Error:
test: #index when loggeed in should display date information on an accepted friendship. (UserFriendshipsControllerTest):
ArgumentError: Factory not registered: accepted_user_friendship Fourth 3) Error:
test: #index when loggeed in should display friend's names. (UserFriendshipsControllerTest):
ArgumentError: Factory not registered: accepted_user_friendship
Fifth 4) Error:
test: #index when loggeed in should display pending information on a pending friendship. (UserFriendshipsControllerTest):
ArgumentError: Factory not registered: accepted_user_friendship Sixth 5) Error:
test: #index when loggeed in should get the index page without error. (UserFriendshipsControllerTest):
ArgumentError: Factory not registered: accepted_user_friendship Seventh 6) Error:
test: #index when not logged in should redirect to login page. (UserFriendshipsControllerTest):
ActionController::RoutingError: No route matches {:controller=>"user_friendships"} Eighth1) Error:
test_that_adding_a_friend_works(AddAFriendTest):
NoMethodError: undefined method `sign_in_as' for #<AddAFriendTest:0x000000039a0a58>
/home/jure/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.14/lib/action_dispatch/testing/assertions/routing.rb:176:in `method_missing'
/home/jure/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.14/lib/action_dispatch/testing/integration.rb:386:in `method_missing'
/home/jure/projects/treebook/test/integration/add_a_friend_test.rb:9:in `block in <class:AddAFriendTest>' Ninth Errors running test:units! #<RuntimeError: Command failed with status (1): [ruby -I"lib:test" -I"/home/jure/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-10.1.0/lib" "/home/jure/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-10.1.0/lib/rake/rake_test_loader.rb" "test/unit/**/*_test.rb" ]>
Errors running test:functionals! #<RuntimeError: Command failed with status (6): [ruby -I"lib:test" -I"/home/jure/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-10.1.0/lib" "/home/jure/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-10.1.0/lib/rake/rake_test_loader.rb" "test/functional/**/*_test.rb" ]>
Errors running test:integration! #<RuntimeError: Command failed with status (1): [ruby -I"lib:test" -I"/home/jure/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-10.1.0/lib" "/home/jure/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-10.1.0/lib/rake/rake_test_loader.rb" "test/integration/**/*_test.rb" ]>
Thank you for your help!
1 Answer
Ralph Robot
217 PointsIt looks like most of the errors are due to the accepted_user_friendship factory not being registered.
Have you defined that factory in a test/factories.rb or test/factories/*.rb file? It would look something like this:
FactoryGirl.define do
factory : accepted_user_friendship do
end
end