Created
November 21, 2012 07:10
-
-
Save chendo/4123532 to your computer and use it in GitHub Desktop.
WillPaginate::Collection and RSpec's =~ operator fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Seeing really confusing RSpec output like this? | |
# Failure/Error: obj.will_paginated_array.map(&:id).should =~ [foo.id, bar.id] | |
# expected: [1, 2] | |
# got: [1, 2] (using =~) | |
# (WillPaginate::Collection#map returns WillPaginate::Collection instance) | |
# This is due to how OperatorMatcher simply does a lookup of the class of the actual | |
# result rather and checking a hash rather than using #is_a?(klass) | |
# | |
# This snippet below will make it work again. | |
RSpec::Matchers::OperatorMatcher.register(WillPaginate::Collection, '=~', RSpec::Matchers::BuiltIn::MatchArray) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment