Facing an energized Democratic opponent, the Texas attorney general is testing whether party loyalty can overcome voters’ reservations about him.