Rotation are done around an axis, so you need to access the good component. However, transform.rotation is a quaternion, which is a little complicated. But you can use the property eulerAngles. So, to test the rotation around the y axis :
What are you using it for exactly? Do you want to know if something rotated 180 degrees in any combination of directions? About a single axis? Is the rotation relative to another object, like trying to detect if something is facing opposite to something else?