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
, en particulier pour « ne met pas en évidence sur l'action erronée » scénarios, mais je pense c'est assez bon.
La raison pour laquelle je voulais le tester parce que c'était un plugin Rails (tabnav), pas purement une chose de conception. Si vous jetez un oeil à ce pastie ici http://pastie.org/961207, je pense que vous verrez pourquoi je veux le tester. Pour répondre à votre question je veux tester si elle met en évidence sur la bonne page ou non. Le fonctionnement de tabnav est que si je suis sur un certain contrôleur et une action, il met en évidence/change la couleur du lien particulier. Merci. –
Je soupçonne que tabnav applique une classe CSS. Tirez le document HTML, recherchez ce que la classe est, et tester pour cela :) Ce cas tomberait sous le premier paragraphe de cette réponse, la structure HTML, plutôt que les deux derniers. – Matchu
... en fait, maintenant que je pense à travers cela, devriez-vous même tester les fonctionnalités de base de tabnav? Si c'est déjà testé, faites-lui confiance. – Matchu