0

更新: 運動前の状態に戻し、ユーザー仕様を「パスワード確認」ではなく「確認」に変更することで解決しました

describe "with valid information" do
      before do
        fill_in "Name", with: "Example User"
        fill_in "Email", with: "user@example.com"
        fill_in "Password", with: "foobar"
        fill_in "Confirmation", with: "foobar"
      end

それらの演習を行った人は誰でも私を助けることができますか?

残念ながら、サインアップ フォームと編集フォームで古いバージョンのエラー メッセージ パーシャルが使用されているため、ユーザー リクエストの仕様は壊れています。それらを修正するために、リスト 10.36 とリスト 10.37 に示すように、より一般的なバージョンに更新します。(注: セクション 9.6 の演習からリスト 9.50 とリスト 9.51 を実装した場合、コードは異なります。必要な変更を加えてください。)

Failures:

  1) User pages signup with valid information should create a user
     Failure/Error: fill_in "Name",         with: "Example User"
     Capybara::ElementNotFound:
       cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
     # (eval):2:in `fill_in'
     # ./spec/requests/user_pages_spec.rb:104:in `block (4 levels) in <top (required)>'

  2) User pages signup with valid information after saving the user
     Failure/Error: fill_in "Name",         with: "Example User"
     Capybara::ElementNotFound:
       cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
     # (eval):2:in `fill_in'
     # ./spec/requests/user_pages_spec.rb:104:in `block (4 levels) in <top (required)>'

  3) User pages signup with valid information after saving the user
     Failure/Error: fill_in "Name",         with: "Example User"
     Capybara::ElementNotFound:
       cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
     # (eval):2:in `fill_in'
     # ./spec/requests/user_pages_spec.rb:104:in `block (4 levels) in <top (required)>'

  4) User pages signup with valid information after saving the user
     Failure/Error: fill_in "Name",         with: "Example User"
     Capybara::ElementNotFound:
       cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
     # (eval):2:in `fill_in'
     # ./spec/requests/user_pages_spec.rb:104:in `block (4 levels) in <top (required)>'

  5) User pages edit with valid information
     Failure/Error: fill_in "Name",             with: new_name
     Capybara::ElementNotFound:
       cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
     # (eval):2:in `fill_in'
     # ./spec/requests/user_pages_spec.rb:150:in `block (4 levels) in <top (required)>'

  6) User pages edit with valid information
     Failure/Error: fill_in "Name",             with: new_name
     Capybara::ElementNotFound:
       cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
     # (eval):2:in `fill_in'
     # ./spec/requests/user_pages_spec.rb:150:in `block (4 levels) in <top (required)>'

  7) User pages edit with valid information
     Failure/Error: fill_in "Name",             with: new_name
     Capybara::ElementNotFound:
       cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
     # (eval):2:in `fill_in'
     # ./spec/requests/user_pages_spec.rb:150:in `block (4 levels) in <top (required)>'

  8) User pages edit with valid information
     Failure/Error: fill_in "Name",             with: new_name
     Capybara::ElementNotFound:
       cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
     # (eval):2:in `fill_in'
     # ./spec/requests/user_pages_spec.rb:150:in `block (4 levels) in <top (required)>'

  9) User pages edit with valid information
     Failure/Error: fill_in "Name",             with: new_name
     Capybara::ElementNotFound:
       cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
     # (eval):2:in `fill_in'
     # ./spec/requests/user_pages_spec.rb:150:in `block (4 levels) in <top (required)>'

Finished in 5.78 seconds
112 examples, 9 failures

Failed examples:

rspec ./spec/requests/user_pages_spec.rb:119 # User pages signup with valid information should create a user
rspec ./spec/requests/user_pages_spec.rb:116 # User pages signup with valid information after saving the user
rspec ./spec/requests/user_pages_spec.rb:115 # User pages signup with valid information after saving the user
rspec ./spec/requests/user_pages_spec.rb:114 # User pages signup with valid information after saving the user
rspec ./spec/requests/user_pages_spec.rb:158 # User pages edit with valid information
rspec ./spec/requests/user_pages_spec.rb:159 # User pages edit with valid information
rspec ./spec/requests/user_pages_spec.rb:157 # User pages edit with valid information
rspec ./spec/requests/user_pages_spec.rb:160 # User pages edit with valid information
rspec ./spec/requests/user_pages_spec.rb:161 # User pages edit with valid information

これは、演習によって変更されたため、リストからの現在の (間違った) コードです。

edit.html.erb

<% provide(:title, 'Edit user') %> 
<h1>Update your profile</h1>

<div class="row">
  <div class="span6 offset3">
    <%= form_for(@user) do |f| %>
      <%= render 'shared/error_messages', object: f.object %>
      <%= f.submit "Save changes", class: "btn btn-large btn-primary" %>
    <% end %>
    <%= gravatar_for @user %>
    <a target="_blank" href="http://gravatar.com/emails">change</a>
  </div>
</div>

new.html.erb

<% provide(:title, 'Sign up') %>
<h1>Sign up</h1>

<div class="row">
  <div class="span6 offset3">
    <%= form_for(@user) do |f| %>
      <%= render 'shared/error_messages', object: f.object %>
      <%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
    <% end %>
  </div>
</div>

リスト9.50。新規および編集フォーム フィールドのパーシャル。

アプリ/ビュー/ユーザー/_fields.html.erb

<%= render 'shared/error_messages' %>

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

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

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

<%= f.label :password_confirmation, "Confirm Password" %>
<%= f.password_field :password_confirmation %>

リスト9.51。部分的な新しいユーザー ビュー。

/users/new.html.erb

<% provide(:title, 'Sign up') %>
<h1>Sign up</h1>

<div class="row">
  <div class="span6 offset3">
    <%= form_for(@user) do |f| %>
      <%= render 'fields', f: f %>
      <%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
    <% end %>
  </div>
</div>
app/views
4

1 に答える 1

0

更新: 運動前の状態に戻し、ユーザー仕様を「パスワード確認」ではなく「確認」に変更することで解決しました

describe "with valid information" do
      before do
        fill_in "Name", with: "Example User"
        fill_in "Email", with: "user@example.com"
        fill_in "Password", with: "foobar"
        fill_in "Confirmation", with: "foobar"
      end
于 2013-04-23T16:11:20.017 に答える