Seeing as it doesn't have weather sealing like the pro bodies, there probably hasn't been much testing. The best thing to do, is probably what you did....when it starts raining, put it away. Of course, there are several ways to cover your camera and continue to shoot in the rain.
Actually, I accidentally did some wet weather testing with my Canon 20D. I was in Costa Rica and I went on a 'Rain Forest Canopy Tour'. It was a zip-line adventure, so we had to wear a harness and other safety gear...which meant that I couldn't bring my camera bag (backpack). When we left base camp, it wasn't raining so I brought my camera with me. We rode horseback and then hiked up to the starting point, and by that time it had started to rain. A little later and we were up in the trees in a torrential downpour. I had a shower cap in my pocket, so I put that over the camera as best as I could. I couldn't even hold the camera while on the zip line because it required two hands.
Anyway, the camera got completely soaked.
I took the battery out and tried to dry it off as best I could. It stopped raining on the way back to the base camp and I actually got some pretty good photos. When we got back into the van, the LCD screen started to fog up, on the inside. It was a day or two before the screen cleared up completely...but the camera suffered no ill effects...and is still working great, a few years later.
Maybe I got really lucky or maybe these things aren't as delicate as we think. Either way, I don't recommend trying that...but it's good to know that it could handle it.
I'm not sure how well the D40 compares to the 20D.