improved `assert_template` when matching :locals

This PR improves two aspects of `assert_template` when used with the :locals option.

### 1. descriptive error message when the partial wasn't rendered

When `assert_template` is used with the :locals option, and the partial was not rendered, a method_missing error was raised. This changes first checks, if the partial actually was rendered and raises a descriptive error.

### 2. recognize partial inside a directory

previously when a partial was placed inside a directory (eg. '/dir/_partial'), `assert_template` did not replace the '_' prefix when looking through rendered tempaltes, which resulted in an error.
    
I modified it to replace both, the leading '_' and the last '_' after a '/'.

This is a fix for #8516