0
我是新來的紅寶石在軌道上。我正在做測試驅動開發。當我運行我的測試,我得到以下錯誤:水豚:: ElementNotFound
1) User Signs Up for Blocitoff Successfully
Failure/Error: fill_in 'user_name', with: 'Joe User'
Capybara::ElementNotFound:
Unable to find field "user_name"
# ./spec/features/user_signs_up_spec.rb:6:in `block (2 levels) in <top (required)>'
這是我的規格:
require 'rails_helper'
feature 'User Signs Up for Blocitoff' do
scenario 'Successfully' do
visit new_user_path
fill_in 'User name', with: 'Joe User'
fill_in 'User email', with: '[email protected]'
fill_in 'User password', with: 'joepassword'
click_button 'Save'
end
end
這是我的應用程序/視圖/用戶/ new.html.erb文件:
<%= form_for User.new do |form| %>
<%= form.text_field :user_name, placeholder: 'User Name' %>
<%= form.text_field :user_email, placeholder: 'User Email' %>
<%= form.text_field :user_password, placeholder: 'User Password' %>
<%= form.submit 'Save' %>
<% end %>
這是users_controller.rb:
class UsersController < ApplicationController
def new
end
end
氏s是我的移民文件:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :user_name
t.string :user_email
t.string :user_password
t.timestamps
end
end
end
我認爲這是某種形式的命名規範,應用程序/視圖/ new.html.erb之間的衝突,以及遷移。任何幫助將不勝感激...
工作!非常感謝! – 2014-09-29 17:40:34