circleci / bond

spying for tests
128 stars 28 forks source link

Preserve spec instrumentation when stubbing #46

Open glenjamin opened 5 years ago

glenjamin commented 5 years ago

Spec instrumentation as implemented by spec itself and orchestra both work by altering the var root to wrap the original function with extra behaviour that checks the spec registry and raises errors.

Because bond also replaces the var when doing stubbing, this instrumentation gets lost.

I think it would be useful if spec instrumentation was maintained during stubbing, to ensure that any stubbed behaviour adheres to the spec of the real implementation.

One suggestion from @ericfode was that rather than teach bond about spec instrumentation, we could teach the instrumentation about bond. Bond itself would then need some fairly generic code to pick up metadata and apply additional transformations after stubbing.

What do people think?