Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define traverse methods in proper context #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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