사양

2017-12-01 3 views
1

나는 다음과 같은 요소를 포함 RSpec에에서보기 테스트를 작성하는 깨끗한 방법 찾기 위해 노력하고있는 부트 스트랩 연결 그래프를 테스트하는 방법 : 내가하고 싶은 무엇사양

<a href="/things/2/widgets"> 
    <span class="glyphicon glyphicon-share-alt inline"></span> 
</a> 

테스트입니다 페이지가 뷰 테스트에서 렌더 될 때 'glyphicon-share-alt'는 widgets_things_path에 연결됩니다.

어떻게하면 좋을지 생각해보십시오.

답변

2

당신은 특정 앵커를 확인 have_css을 사용할 수 있으며, 다음의 특정 태그 확인 :

require 'rails_helper' 

RSpec.describe Model, type: :feature do 
    before { visit some_path } 
    let(:anchor) { 'a[href="url"]' } 

    it 'has an anchor with specific url' do 
    expect(page).to have_css anchor 
    end 

    it 'has a specific span inside anchor' do 
    expect(page).to have_css "#{anchor} > span.glyphicon.glyphicon-share-alt.inline" 
    end 
end