Ruby on rails 在使用cucumber进行测试时添加要设计的自定义字段时出现问题

Ruby on rails 在使用cucumber进行测试时添加要设计的自定义字段时出现问题,ruby-on-rails,cucumber,Ruby On Rails,Cucumber,我在使用Desive的Rails应用程序中添加了一个username字段。我完成了所有必要的步骤,如将字段添加到视图、将其添加到用户模型、迁移数据库等。现在,当我手动完成注册步骤时,一切正常。但是,当我试图用Cucumber写一篇专题文章时,我就收到了一大堆错误 下面是我在运行cucumber特性时遇到的错误的简短列表 Scenario: New user registration with valid info # features/user_access.feature:7 When I

我在使用Desive的Rails应用程序中添加了一个
username
字段。我完成了所有必要的步骤,如将字段添加到视图、将其添加到
用户
模型、迁移数据库等。现在,当我手动完成注册步骤时,一切正常。但是,当我试图用Cucumber写一篇专题文章时,我就收到了一大堆错误

下面是我在运行cucumber特性时遇到的错误的简短列表

  Scenario: New user registration with valid info # features/user_access.feature:7
When I sign up as a new user with valid info  # features/step_definitions/user_access_steps.rb:5
  undefined method `username' for #<User:0x00000102f7dcf0> (ActionView::Template::Error)
  /Users/Daniel/.rvm/gems/ruby-1.9.2-p136@Flow1/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:364:in `method_missing'
  /Users/Daniel/.rvm/gems/ruby-1.9.2-p136@Flow1/gems/activerecord-3.0.3/lib/active_record/attribute_methods.rb:46:in `method_missing'
  /Users/Daniel/.rvm/gems/ruby-1.9.2-p136@Flow1/gems/actionpack-3.0.3/lib/action_view/helpers/form_helper.rb:1019:in `value_before_type_cast'
  /Users/Daniel/.rvm/gems/ruby-1.9.2-p136@Flow1/gems/actionpack-3.0.3/lib/action_view/helpers/form_helper.rb:1007:in `value_before_type_cast'
  /Users/Daniel/.rvm/gems/ruby-1.9.2-p136@Flow1/gems/actionpack-3.0.3/lib/action_view/helpers/form_helper.rb:915:in `block in to_input_field_tag'
  /Users/Daniel/.rvm/gems/ruby-1.9.2-p136@Flow1/gems/actionpack-3.0.3/lib/action_view/helpers/form_helper.rb:915:in `fetch'
场景:使用有效信息注册新用户#功能/用户访问权限。功能:7
当我以新用户身份注册时,使用有效的信息#功能/步骤定义/用户访问步骤。rb:5
#的未定义方法“username”(ActionView::Template::Error)
/Users/Daniel/.rvm/gems/ruby-1.9.2-p136@Flow1/gems/activemodel-3.0.3/lib/active\u model/attribute\u methods.rb:364:in'method\u missing'
/Users/Daniel/.rvm/gems/ruby-1.9.2-p136@Flow1/gems/activerecord-3.0.3/lib/active\u record/attribute\u methods.rb:46:in'method\u missing'
/Users/Daniel/.rvm/gems/ruby-1.9.2-p136@Flow1/gems/actionpack-3.0.3/lib/action\u view/helpers/form\u helper.rb:1019:in'value\u before\u type\u cast'
/Users/Daniel/.rvm/gems/ruby-1.9.2-p136@Flow1/gems/actionpack-3.0.3/lib/action\u view/helpers/form\u helper.rb:1007:in'value\u before\u type\u cast'
/Users/Daniel/.rvm/gems/ruby-1.9.2-p136@Flow1/gems/actionpack-3.0.3/lib/action\u view/helpers/form\u helper.rb:915:in'block in to\u input\u field\u tag'
/Users/Daniel/.rvm/gems/ruby-1.9.2-p136@Flow1/gems/actionpack-3.0.3/lib/action\u view/helpers/form\u helper.rb:915:in'fetch'
我已将错误与我的设想隔离开来。出于某种原因,cucumber不喜欢下面这句话

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! % >

<p><%= f.label :username %><br />
<%= f.text_field :username %></p>
resource_name,:url=>registration_path(resource_name))do | f |%>

由于某些原因,cucumber无法很好地处理:username标签和text_字段。我在cucumber步骤中所做的就是进入注册页面,尝试用名称填写
username


知道是什么导致了这个错误以及如何修复它吗?

您更新了测试数据库了吗<代码>rake db:test:prepare

顺便说一句,您是否仅仅通过查看错误就意识到这是db?