Skip to content

Conversation

@mcountis
Copy link

In the same spirit as how RSpec::Matchers::define evaluates given blocks in the context of a class/module, evaluate blocks given to RSpec::JsonExpectations::MatcherFactory#define_matcher in the same manner. Any methods defined in the given block will be defined as instance methods on the new Matcher rather than in a main/global context.

Partially addresses #28 (warnings about #traverse getting redefined).

I'm guessing the original intent of the blocks provided to
MatcherFactory were to mimic blocks provided to RSpec::Matchers.define
calls. In that spirit, evaluate the provided block in the module context
of RSpec's original matcher definition method so that any methods
defined within the block are defined on the module/class rather than in
a main/global context.

This alleviates warning messages about the traverse method already being
defined in the context and getting redefined.
@mcountis
Copy link
Author

@waterlink / @alex-fedorov, do you still manage this repo? If not, have you any thoughts about passing it on to another user?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant