thoughtworks/pacto — pull request #39 by maxlinc (2013-09-30 05:29:52+00:00)
Title: Test cleanup fixes (and bugfixes it caught)

I ran into a lot of problems trying to make #32 work. I've pulled cherry-picked the issues that were fixing test problems or pre-existing bugs, so that if you diff this branch with issue32 you can clearly see the new feature.

A few of these issues are obsoleted or greatly simplified by #32. It might still be worth considering using this branch to help diff, but still merging via #32.

The major problems I fixed were:
- [x] WebMock.reset! does not clear callbacks. As a result, the WebMock after request hook could go to one BuiltIn instance while the values were stored on another. BuiltIn no longer stores values (or any internal state at all) on Issue32.
- [x] Pacto.contract_for was inadvertently modifying the registered contracts. This was surprise of Set#merge changing the set. There is no Set#merge! This became more of an issue in issue32, because we make more use of Pacto.contract_for.

More minor fixes or simplifications:
- [x] Use rspec rake tasks instead of system. This should make sure we don't lose the bundler/rvm/rbenv environment and should be slightly faster.
- [x] Eliminate multiple .rspec* files, which caused confusion about running a single test.
- [x] Avoid the method name stub!, since rspec adds it to Object. Switched to stub_contract! and stub_request!
- [x] Ensure configuration is cleared between each test scenario, and that tests that require templating do not use strict request matching.