1
테스트 유닛에서 테스트를 Rspec/capybara로 다시 쓰고 있습니다. 올바른 구문을 찾기 위해 노력하고 있습니다. root_path를 치고 '/'(헤더에 있음)에 정확히 하나의 링크가 있는지 확인하고 싶습니다.정확한 링크 수가 Rspec과 일치하는지 확인하십시오.
이전 테스트의 관련 부분이었다 :
test 'layout links' do
get root_path
assert_select 'a[href=?]', root_path, count: 1
end
내가 사용 RSpec에와 링크의 존재 여부를 테스트 할 수 있습니다
it 'should have correct number of links' do
visit root_path
expect(page).to have_link('Site Name', root_path)
end
을 내가
expect(page).to have_link('Site Name', root_path, count: 1)
를 추가 시도
하지만 0..2 인수 만 사용합니다.
완벽하게 작동합니다. 감사합니다! – oneWorkingHeadphone