Estoy aprendiendo a hacer pruebas ahora mismo, pero tengo algunos problemas con Webrat al no encontrar campos de formulario usando fill_in
aunque he verificado que está en la página correcta. ¿Funciona Webrat sin nombres de campo o ID? He intentado usar símbolos de Ruby y nombres de formularios para acceder al campo, pero ninguno funciona en mi caso. ¿Ves algo incorrecto con mi implementación?Rails 3 pruebas de integración - Usar webrat fill_in sin encontrar campos
El mensaje de error:
5) Forwarding should forward the user to the requested page after signin
Failure/Error: integration_sign_in(user)
Could not find field: :email
El código de prueba:
it "should forward the user to the requested page after signin" do
user = Factory(:user)
visit edit_user_path(user)
# The test automatically follows the redirect to the signin page
puts current_url
integration_sign_in(user)
# The test follows the redirect again, this time to users/edit
response.should render_template('users/edit')
end
donde integration_sign_in
es en el spec_helper.rb
def integration_sign_in(user)
fill_in :email, :with => user.email
fill_in :password, :with => user.password
click_button
end
El campo de formulario HTML:
<form action='/sessions' class='mtm' id='sign-in-form' method='post'>
<input name='authenticity_token' type='hidden' value='iIIqT6bUwiJkpqpgxm5sjAj3egrNcEgeXPsYmbKQ02U='>
<div class='landingSignInForm'>
<label class='mas signin-label' for='email'>E-mail:</label>
<input class="mls ras" id="email" name="email" placeholder="e-mail address" type="text" />
<label class='mas signin-label' for='password'>Password:</label>
<input class="mls ras" id="password" name="password" placeholder="password" type="password" />
<input checked='checked' class='mls mtm' name='remember' type='checkbox' value='permanent'>
<span class='remember-me-label'>Keep me signed in</span>
<input class='mls mvm ram medium silver button' name='submit' type='submit' value='Sign in'>
<a class='forgot-password' href='#'>Forget your password?</a>
</div>
</form>
Gracias por la respuesta Brett. Lamentablemente, ninguno de los trabajos anteriores (símbolos, nombres, ID, etc.). Estoy casi listo para renunciar a Webrat e instalar Capybara para ver si es solo un problema de Webrat – iwasrobbed
No tengo idea, entonces, lo siento, no pude ayudar más. ¡Buena suerte! –
¡No se preocupe, gracias otra vez! – iwasrobbed