Do Weapon Focus and & Weapon Specialization work with ray spells
No, it doesn't
Unlike pathfinder, rays are not a valid choice for Weapon Focus, as the wording on the feat is different, and it requires a weapon type:
Chose one weapon type (small arms, longarms, heavy weapons, etc.).
Weapon types are well defined in the system, and are as follows:
- Basic Melee
- Advanced Melee
- Small Arms
- Heavy Weapons
- Sniper Weapons
- Ammunitions & Grenades
- Solarian Weapon Crystals
As you can see, rays are not listed there, in fact, I don't think rays are even a thing in Starfinder, as none of the spells that target EAC or KAC actually say anything about being rays.