mardi 31 mai 2016

Capybara::ElementNotFound: Can't Find Field

I'm just learning feature specs and I'm running into a problem that I can't quite figure out. Capybara::ElementNotFound: when I try to run my test. It's strange because I'm following a template word for word but I'm still getting this error. I'd love some help! Here is my code and error for clarity.

TEST

require "rails_helper"

RSpec.feature "Create a subscriber" do
 scenario "Customer can sign up as a subscriber" do
  visit "/subscribers/new"

  user = User.create!(email: "user@example.com", password: "password")
  fill_in "Email", with: "user@example.com"
  fill_in "Password", with: "password"
  click_button "Sign in"

  fill_in "first_name", with: "Cam"
  fill_in "last_name", with: "Bass"
  fill_in "email", with: "cam@example.com"
  fill_in "phone_number", with: "8269338"

  expect(page).to have_content("Subscriber Has Been Successfully Created")
 end
end

VIEW

  <%= form_for @subscriber do |form| %>
  <div class="form-group">
  <p>
  <%= form.label :first %>
  <%= form.text_field :first_name %>
  </p>
  <p>
  <%= form.label :last %>
  <%= form.text_field :last_name %>
  </p>
  <p>
  <%= form.label :email %>
  <%= form.text_field :email %>
  </p>
  <p>
  <%= form.label :phone %>
  <%= form.text_field :phone_number %>
  </p>
 </div>
<%= form.submit "Sign Up", class: "btn btn-primary" %>

ERROR enter image description here

Aucun commentaire:

Enregistrer un commentaire