I’m working on my first Rails project and am not sure if I’m running this test right. I want to test the view for links that will log the user in. I’ve got the local login working with this test
test 'should have local login button on main page' do get '/' assert_select 'a.local[href="#"]', text: 'Login with your email' end
It feels a little hackish to use the attribute selector like this to test for the link’s destination. So, I’ve got two questions:
Should I be testing the link’s destination in a controller test, or is this strictly a job for integration tests?
Is there a better syntax for checking the link destination in a view? While this works, I’d rather use RESTful route helpers in the test to ensure it’s the same as what’s in the view. I found this very old link, which describes a syntax I’d much rather use:
assert_select ‘a.local’, text: ‘Login with your email’, href: ‘#’
But I can’t make a failing test with this added attribute.