Topic: Rails 3.1 Rspec could not find link with text or title “Sign in”
I'm trying to have Rspec test for user sign in. Here is my view:
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br /><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %><br /><br />
<%= f.password_field :password %></div><br />
<div class = "btn"><%= f.submit "Sign in" %></div>
<% end %>Here is my test:
require 'spec_helper'
describe "Users" do
describe "signin" do
describe "failure" do
it "should not sign a user in" do
visit new_user_session_path
fill_in "email", :with => ""
fill_in "password", :with => ""
click_link "Sign in"
response.should have_selector('div.flash.alert', :content => "Invalid")
response.should render_template('devise/sessions/new')
end
end
end
endand here is the error:
1) Users signin failure should not sign a user in
Failure/Error: click_link "Sign in"
Webrat::NotFoundError:
Could not find link with text or title or id "Sign in"I tried 'click_button' but that but I get a noMethodError so that seems to have been removed. Any ideas? Thanks.