Make some exec_query expectations less fragile between rails versions.

@fbogsany for review

These expectations were failing on rails 4.2.0.rc1 because exec_query took a third parameter and one of the two spaces preceding `WHERE` was removed in the SQL query strings.
pushed the refactoring of this expectation out into a method.