During an rspec
-test, I am attempting to reset my password by filling a form and clicking the "Reset Password" link.
Capybara gives me the following error:
1) ResetPasswords emails user a reset link when resetting password
Failure/Error: click_link 'Reset Password'
Capybara::ElementNotFound:
Unable to find link "Reset Password"
Apparently it does not find the link I want it to click. But when I attempt to print the page on which it is looking with puts page.body
, this element is present:
<div><input name="commit" type="submit" value="Reset Password" /></div>
I've attempted to use click
, click_button
and click_link
, but no cigar.
Why is the element not being found?
Update 1: click_button
output
1) ResetPasswords emails user a reset link when resetting password
Failure/Error: click_button 'Reset Password'
ActionView::Template::Error:
Missing host to link to! Please provide the :host parameter, set
default_url_options[:host], or set :only_path to true
Update 2: Test file
require 'spec_helper'
include Warden::Test::Helpers
Warden.test_mode!
describe "ResetPasswords" do
it "emails user a reset link when resetting password" do
visit login_path
click_link 'password'
fill_in 'Email', :with => @user.email
puts page.body
click_link 'Reset Password'
page.should have_content "You will receive an email"
end
before(:each) do
@user = create(:user)
#login_as @user, :scope => :user
end
end
click_button 'Reset Password'
method? – Ashish Bista