describe 'highlighting' do
it 'should highlight account/settings' do
get '/account/settings'
response.should have_tag("a.active[href=?]", account_settings_path, /Account Settings/i)
end
it 'should highlight account/profile' do
get '/account/profile'
response.should have_tag("a.active[href=?]", account_profile_path, /Profile Information/i)
end
it 'should highlight account/picture' do
get '/account/picture'
response.should have_tag("a.active[href=?]", account_picture_path, /Profile Picture/i)
end
it 'should highlight account/notifications' do
get '/account/notifications'
response.should have_tag("a.active[href=?]", account_notifications_path, /Notifications/i)
end
it 'should not highlight Profile' do
get '/account/profile'
response.should_not have_tag("a.active[href=?]", account_settings_path, /Account Settings/i)
end
it 'should not highlight Notifications' do
get '/account/profile'
response.should_not have_tag("a.active[href=?]", account_notifications_path, /Notifications/i)
end
it 'should not highlight Picture' do
get '/account/profile'
response.should_not have_tag("a.active[href=?]", account_picture_path, /Profile Picture/i)
end
end
당신은 시나리오 "잘못된 행동에 강조하지 않는다"특히에 대한 더 많은 테스트를 작성할 수 있지만 내 생각 이 정도면 충분합니다. 당신이 말대꾸를 사용하는 경우
내가 레일스 플러그인 (tabnav) 이었기 때문에 그것을 테스트하고 싶었던 이유는 순수하게 디자인적인 것이 아니기 때문입니다. 이 pastie를 http://pastie.org/961207에서 보면 왜 내가 테스트하고 싶은지 알 것입니다. 질문에 답하기 위해 적절한 페이지에서 강조 표시했는지 여부를 테스트하고 싶습니다. tabnav가 작동하는 방식은 특정 컨트롤러 및 작업에있는 경우 특정 링크의 색상을 강조 표시하거나 변경하는 것입니다. 감사. –
나는 tabnav가 CSS 클래스를 적용한다고 생각합니다. HTML 문서를 가져 와서 클래스가 무엇인지 찾아보고이를 테스트하십시오.이 경우는 마지막 두 개가 아닌이 응답의 첫 번째 단락 인 HTML 구조에 해당합니다. – Matchu
... 사실, 이제 이것을 통해, 당신은 tabnav의 기본 기능을 테스트해야할까요? 이미 철저히 테스트 된 것이라면 그냥 신뢰하십시오. – Matchu