Search⌘ K

Passing the Third Test

Explore how to pass the third feature test by fixing registration links and routes in Rails. Learn to integrate Devise for user registration, customize form fields by adding a user name attribute, and adjust test selectors to match Rails-generated IDs, ensuring your registration feature works correctly.

We need to do a few things to pass the third test.

Fixing the registration link

Let’s fix the link first by replacing the empty path with the registration path.

HTML
<%= link_to "Registration", registration_path, id: "registration-link" %>

Note: You need to add the code above to the SPA.

Bud1  Glg1Scomp @� @� @� @G.gitlg1ScompK�.gitmoDDblob�B�A.gitmodDblob�B�A.gitph1ScompappIlocblob;(������applg1Scomp#appmoDDblob�B�AappmodDblob�B�Aappph1Scomp�binIlocblob�(������binlg1Scomp�binmoDDblob�B�AbinmodDblob�B�Abinph1Scomp0configIlocblob(������configlg1ScompK�configmoDDblob�:S�AconfigmodDblob�:S�Aconfigph1Scomp@	config.ruIlocblob�(������dbIlocblob�(������dblg1ScompvdbmoDDblob��O�AdbmodDblob��O�Adbph1ScompfeaturesIlocbloba(������featureslg1ScompMfeaturesmoDDblob�O�AfeaturesmodDblob�O�Afeaturesph1Scomp0GemfileIlocblob;�������Gemfile.lockIlocblob��������libIlocblob�������liblg1Scomp	TlibmoDDblob�B�AlibmodDblob�B�Alibph1ScomplogIlocblob��������loglg1ScompnlogmoDDblob�O�AlogmodDblob�O�Alogph1ScomppublicIlocblob��������publiclg1Scomp)publicmoDDblob�B�ApublicmodDblob�B�Apublicph1Scomp@RakefileIlocbloba�������	README.mdIlocblob;������scriptIlocblob�������scriptlg1ScompOscriptmoDDblob�O�AscriptmodDblob�O�Ascriptph1ScompstorageIlocblob������storagelg1ScompstoragemoDDblob�B�AstoragemodDblob�B�Astorageph1ScomptmpIlocblob�������tmpbwspblob�bplist00�


]ShowStatusBar[ShowPathbar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowSidebar		_{{378, 278}, {1136, 674}}	%1=I`myz{|}~��tmplg1Scomp�qtmpmoDDblob�O�AtmpmodDblob�O�Atmpph1Scomp=0tmpvSrnlongvendorIlocblob�������vendorlg1ScompvendormoDDblob�B�AvendormodDblob�B�Avendorph1Scomp EDSDB `�(0@� @� @�������loglg1ScompnlogmoDDblob�O�AlogmodDblob�O�Alogph1ScomppublicIlocblob��������publiclg1Scomp)publicmoDDblob�B�ApublicmodDblob�B�Apublicph1Scomp@RakefileIlocbloba�������	README.mdIlocblob;������scriptIlocblob�������scriptlg1ScompOscriptmoDDblob�O�AscriptmodDblob�O�Ascriptph1ScompstorageIlocblob������storagelg1ScompstoragemoDDblob�B�AstoragemodDblob�B�Astorageph1Scomp
The third test

Running the test after updating the link produces the following error:

Undefined local variable or method `registration_path'

That’s much better.

Adding the route

This error says that there’s no route for the registration page. That’s because we haven’t created one yet. We’ll do that now by adding the registration route to config/routes.rb.

Ruby
Rails.application.routes.draw do
get "/registration", to: "registrations#new"
root "site#index"
end

Rerun the test after adding the routes in the widget above. It now produces the following error:

Uninitialized constant RegistrationsController
...