There really is no such thing as a ray, an infinitely thin beam of light. But thinking about light in terms of rays can make understanding it much easier. You can picture light as traveling out from objects in straight lines. The light ray model of how light travels is useful because it is consistent with many phenomena that we observe. In the case of pinholes, the observation that you can draw a straight line between a light source, a pinhole, and the image of the light source on a screen, is consistent with a straight line, ray model of light.
Some textbooks describe light being able to bend.
This can be confusing when trying to reconcile this thought with light traveling in a straight line. Light bends when it travels from one medium to another, such as from air into a prism or lens. This does not happen in the case of pinholes. The notion that light travels in infinitely thin, straight lines and emanates from every point on a light source in all directions is complicated, and an abstraction of the real world. These examples are meant to give you some additional ways to feel more comfortable with the difficult concept of light rays.