I am studying testing right now, but I am having some problems with the fact that Webrat does not find the form field using fill_in, although I checked that it is on the correct page. Does Webrat work with field names or identifiers? I tried using Ruby characters and form names to access the field, but none of them work in my case. Do you see something wrong in my implementation?
Error message:
5) Forwarding should forward the user to the requested page after signin
Failure/Error: integration_sign_in(user)
Could not find field: :email
Security Code:
it "should forward the user to the requested page after signin" do
user = Factory(:user)
visit edit_user_path(user)
puts current_url
integration_sign_in(user)
response.should render_template('users/edit')
end
where integration_sign_inis inspec_helper.rb
def integration_sign_in(user)
fill_in :email, :with => user.email
fill_in :password, :with => user.password
click_button
end
HTML form field:
<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>
source
share