I've noticed that I'm not 100% on when I can cancel terms. Say we got $\displaystyle \frac{x^2+3x-2}{x^2-3x-2}$ can I cancel out all the terms and get 1? What about $\displaystyle \frac{x^3+3x-2}{x^2+3x}$ can I cancel out everything except -2? What if -2 is in the denominator?

Please provide as detailed descriptions as you can. I need to nail this. Thanks.