nit: put the spy in a setup() function (as same below)

also, should you spy ensureFilenameMatchesType as well ?