0

Railsチュートリアルに従って、Rails4アプリケーションに取り組んでいます。認証サインイン ページのテスト中にエラーが発生しました。エラーメッセージは次のとおりです。

Failure/Error: fill_in "email",    with: user.email.upcase
 Capybara::ElementNotFound:
   Unable to find field "email"
 # ./spec/requests/authentication_pages_spec.rb:35:in `block (3 levels) in <top (required)>'

私の session#new.html.erb にはそのような要素がありますが:

<%= form_for(:session, url: sessions_path) do |f| %>

  <%= f.label :email %>
  <%= f.text_field :email %>

  <%= f.label :password %>
  <%= f.password_field :password %>

  <%= f.submit "Sign in", class: "btn btn-large btn-primary" %>
<% end %>

これが私の authentication_pages_spec.rb 相対テスト部分です:

describe "with valid information" do # signin with valid information
      let(:user) { FactoryGirl.create(:user) }
      before do
        fill_in "email",    with: user.email.upcase
        fill_in "password", with: user.password
        click_button "Sign in"
      end

      it { should have_title(user.name) }
      it { should have_link('Profile',     href: user_path(user)) }
      it { should have_link('Sign out',    href: signout_path) }
      it { should_not have_link('Sign in', href: signin_path) }

      describe "followed by signout" do
        before { click_link "Sign out" }
        it { should have_link('Sign in') }
      end
   end

テスト セクションに「visit signin_path」を追加しようとしましたが、同じメッセージで失敗します。誰かが私がどこで間違いを犯したかを理解するのを手伝ってくれませんか? どうもありがとう。

4

1 に答える 1