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

Already on GitHub? Sign in to your account

have_index matcher doesn't support compound indexes #15

Merged
merged 4 commits into from Jan 3, 2013

Conversation

Projects
None yet
2 participants
Collaborator

rmm5t commented Jan 3, 2013

There's no way to ensure that a compound index exists on a collection. Currently, the matcher only supports single-field indexes.

I'd like to be able to specify a matcher against a compound index like so:

    it { must have_index_for(:account_id, :email) }

Pull request in the works...

Collaborator

rmm5t commented Jan 3, 2013

@frodsan Pull-request, as promised. Please let me know if you have any questions.

Collaborator

rmm5t commented Jan 3, 2013

I should also mention that as part of this enhancement, I chose to remove support for automatically appending _id to fields passed to the matcher. This simplifies the matcher, but more importantly, it makes the matcher explicit. Just because Mongoid has a facilitator for adding indexes to relationships doesn't mean that the test needs to mimic that exactly.

Here's an example change of what that decision requires:
rmm5t/mongoid-minitest@074b5ff#L1R22

@frodsan frodsan pushed a commit that referenced this pull request Jan 3, 2013

Francesco Rodríguez Merge pull request #15 from rmm5t/compound-indexes
have_index matcher doesn't support compound indexes
d22c20a

@frodsan frodsan merged commit d22c20a into frodsan:master Jan 3, 2013

1 check passed

default The Travis build passed
Details
Owner

frodsan commented Jan 3, 2013

Nice, Thank you 😄

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