rspec - Rails 3 integration testing - Using webrat fill_in not finding fields -


I'm just learning the test, but there are some problems with Webrat that fill_in even if I Verified that this is on the right page. Does the Webrat area work away from the name or id? I have tried to use Ruby symbols and form names to reach the field, but no one works in my case. Do not you see anything wrong with your implementation?

Error message:

  5) The forwarding user should be sent to the requested page after the sign in failure / error: integration_sign_in (user) field could not be found: Email   

Exam code:

  This user should be sent to the requested page after logging "user = factory (user :) go to edit_user_path (user) # Test automatically triggers signin page current_url integration_sign_in (user) # test again From this time, Redirection for the User / Edit response has the following render_template ('users / edit') End   

Where integration_sign_in is in spec_helper.rb < / Code>

  def integration_sign_in (user) Fill_in: email ,: with = & gt; User.email fill_in: Password, with: with => Form Field HTML:  
  & lt; Form action = '/ sessions' class = 'mtm' id = 'sign-in-form' method = 'post' & gt; & Lt; Input name = 'authentication_token' type = 'hidden' value = 'iiiqT6bUwiJkpqpgxm5sjAj3egrNcEgeXPsYmbKQ02U =' & gt; & Lt; Div class = 'landingSignInForm' & gt; & Lt; Label = 'email signin-label' = 'email' & gt; E-mail: & lt; / Label & gt; & Lt; Input class = "MLS RAS" id = "email" name = "email" placeholder = "e-mail address" type = "text" /> & Lt; Label class = 'password for' mass sign-label '=' password '& gt; Password: & lt; / Labels & gt; & Lt; Input class = "mls ras" id = "password" name = "password" placeholder = "password" type = "password" /> & Lt; Input checked = 'checked' class = 'mls mtm' name = 'remember' type = 'checkbox' value = 'permanent' & gt; & Lt; Span class = 'remember-me-label' & gt; Sign me up & lt; / Span & gt; & Lt; Input class = 'MLS MVM RAM Medium silver button' name = 'Submit' type = 'submit' value = 'log in' & gt; & Lt; A class = 'forgotten password' href = '#' & gt; Forgot your password? & Lt; / A & gt; & Lt; / Div & gt; & Lt; / Form & gt;    

Have you tried using the CDS selector for the id? I tried to read this briefly through the webrat source to determine whether it perceives the signals internally as a string, thinking that this is your problem. Webrat can not find any instance of syntax by using fill_in: symbol only fill_in 'string'

:

  def integration_sign_in (user) fill_in 'email' ,: with = & gt; User.email fill_in 'password' ,: with = & gt; User.Password Click_button End   

or CSS selector path for your ID:

  def integration_sign_in (user) fill_fill '#email', with: = & Gt; User.email fill_in '#password' ,: with = & gt; User.password click_button end    

Comments