pact-foundation / pact-mock_service

Provides a mock service for use with Pact
https://pact.io
MIT License
73 stars 69 forks source link

Arrays in query parameters not translated to have square brackets in the url #60

Closed SushmaShyam closed 7 years ago

SushmaShyam commented 7 years ago

When setting a provider state like:

        some_service.given('some scenario')
          .upon_receiving('a request for questions')
          .with(method: :get, path: '/questions', query: { question_ids: [1,2] })

and sending in query params hash is like this:

query_params_hash = { question_ids: [1,2] }

I encounter the following error:

Missing requests:
                GET /questions?question_ids=1&question_ids=2

            Unexpected requests:
                GET /questions?question_ids[]=1&question_ids[]=2

The square brackets are missing from the expected request

bethesque commented 7 years ago

Note for bug fixing: look here https://github.com/bethesque/pact-mock_service/blob/7d4fd1f8ec6b6f6f118aae56fe6373ebc4f83972/lib/pact/consumer/mock_service/rack_request_helper.rb#L9

bethesque commented 7 years ago

I'm having trouble replicating it. I get this error:

E, [2016-12-08T06:53:22.640303 #13236] ERROR -- : Diff with interaction: "a request for alligators" given "alligators exist"
@@ -1,8 +1,8 @@
 {
   "query": {
     "question_ids": [
-      1,
-      2,
+      "1",
+      "2"
     ]
   }
 }
bethesque commented 7 years ago

@SushmaShyam, can you check if your HTTP client is actually serialising your request with square brackets?

bethesque commented 7 years ago

Closing as no response.