RSpec 테스트를 작성하고 텍스트 필드를 채울 때 다음 오류가 발생합니다.RSpec 테스트를 작성할 때 오류가 발생했습니다. Capybara :: ElementNotFound : 필드를 찾을 수 없습니다.
1) coordinators/new.html.erb populate page name text entry field filled checks for presence of filled in text field
Failure/Error: fill_in "coordinator_name", with: 'JoeJoe'
Capybara::ElementNotFound:
Unable to find field "coordinator_name"
# ./spec/views/coordinators/new.html.erb_spec.rb:47:in `block (4 levels) in <top (required)>'
여기에는 "coordinator_name"필드가있는 앞의 테스트를 포함한 내 코드의 일부입니다. 나는 왜 그것이 2 차 시험에서 발견되지 않는지 혼란 스럽다.
describe 'name text entry field' do
it 'checks for presence of empty text field for name' do
expect(rendered).to have_field('coordinator_name', text: nil)
end
end
describe 'name text entry field filled' do
it 'checks for presence of filled in text field' do
fill_in "coordinator_name", with: 'JoeJoe'
expect(rendered).to have_field('coordinator_name', text: 'JoeJoe')
end
end
해결책을 찾는 방법에 대한 제안이 있으십니까?
테스트 코드에서는 have_field에 ': text' 옵션을 넘기는 것을 보여줍니다 - have_field는': text' 옵션을 취하지 않습니다. 필드의 값을 테스트하려는 경우': with' 옵션을 사용합니다 , 또한 '렌더링'이란 무엇입니까? - 신경 쓰지 마. 네가 뭘 잘못하고 있는지. –
@KevinEtore 빈 파일 (html 없음)입니다. 하지만 "빈 텍스트 필드의 존재 여부 확인"테스트를 위해 save_and_open_page를 넣을 때도 마찬가지입니다 (빈 페이지). – JSmooth