Skip to content


Subversion checkout URL

You can clone with
Download ZIP


WebMock::API.hash_including not working (and causes warnings in Ruby 2.0) #329

steookk opened this Issue · 4 comments

3 participants


It gives these warnings (from what I understood after some searches these warnings only occur in Ruby 2.0)
warning: wrong element type Hash at 0 (expected array)
warning: ignoring wrong elements is deprecated, remove them explicitly
warning: this causes ArgumentError in the next release

The problem is that this method fails in his job:
ie -> if you do define a stub like this:

WebMock::API.stub_request(:post, get_access_token_request).
        with(:body => WebMock::API.hash_including(:code => "test")).

the stub actually responds no matter what the value of :code is (it theory it should only respond when :code == 'test').


Can you please provide a failing code sample?


I fixed it. I'll submit a pull request tomorrow morning with a better explanation.


@steookk, I'm running into the same issue. What did you do to fix it?


Sorry for the late reply. Here is a better explanation:

  • spec/unit/include_spec.rb does not really work even if tests pass. The main problem is that the resulting @expected var in HashIncludingMatcher is always an empty hash. The second problem is that an empty hash always matches true.
    • this behavior happens because of wrong arguments type passed to Hash[..] at line 7 of hash_including_matcher.rb .
  • This behavior does not happen when you use RSpec::Mocks::ArgumentMatchers#hash_including, which happens automatically most of the times since it has the precedence over WebMock::API#hash_including.
  • I wrote tests in this gist. Have a try.
@bblimke bblimke closed this in #332
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.