(maint) use anonymous subclass for mocha stubs

Prior to this commit, specs against 1.8.7 were failing because of
lingering $SAFE=4 side effects from mocha stubbing. This commit uses an
anonymous subclass for the stubbing to prevent global test pollution via
the stubs. Once 1.8.7 is no longer required, this hack can safely be
removed.