私は挑戦を解決しようとしているが、私は言ってCabybaraからエラーメッセージを受信:のRails:カピバラ:: ElementNotFound
`Failure/Error: fill_in 'Name', with: 'Vostro 2017'
Capybara::ElementNotFound: Unable to find visible field "Name" that is not disabled`
マイnew.html.erb
は次のとおりです。
<%= form_for @item, url: {action: "create"} do |f|%>
<%= f.label 'Name' %>
<%= f.text_field :name %>
<%= f.label 'Description' %>
<%= f.text_field :description %>
<%= f.label 'Features' %>
<%= f.text_field :features %>
<%= f.label 'Asset number' %>
<%= f.text_field :assetNumber %>
<%= f.submit%>
<% end %>
そして、私のitem_controller.rb
されます:
class ItemController < ApplicationController
def show
@items = Item.find(params[:id])
end
def new
@item = Item.new
end
def create
@item = Item.new(item_params)
@item.save
redirect_to @item
end
private
def item_params
params.require(:item).permit(:name, :description, :features, :assetNumber)
end
end
テストを行うために使用されているRSpecのファイルは次のとおりです。
require 'rails_helper'
feature 'User creates a new inventory item' do
scenario 'successfully' do
visit new_item_path
fill_in 'Name', with: 'Vostro 2017'
fill_in 'Description', with: 'Dell Notebook'
fill_in 'Features', with: '16gb, 1Tb, 15.6"'
fill_in 'Asset number', with: '392 DLL'
click_button 'Create Item'
expect(page).to have_content 'Vostro 2017'
expect(page).to have_content 'Dell Notebook'
expect(page).to have_content '16gb, 1Tb, 15.6"'
expect(page).to have_content '392 DLL'
end
end
私はruby-2.3.5とrails 4.1.0を使用しています。 私はRuby/Railsの初心者です。私のコードで何が間違っているのか分かりません。 誰かがそれを解決するのに手伝ってもらえますか? 私は前もって感謝します。
質問をモーダルでもplsでも更新できますか? –
@Ziyan Junaideenモーダルとは何ですか? – viniCdaSilva