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