Rails 3.1 Rspec не смог найти ссылку с текстом или заголовком «Войти» - PullRequest
1 голос
/ 02 февраля 2012

Я пытаюсь сделать тест Rspec для входа пользователя. Вот мой взгляд:

<%= 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 %>

Вот мой тест:

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
end

и вот ошибка:

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"

Я попробовал 'click_button', но это, но я получил noMethodError, так что, кажется, был удален.Есть идеи?Благодаря.

1 Ответ

0 голосов
/ 02 февраля 2012

вместо

click_link "Sign in" 

попробуйте

click_button "Sign in"
...