Skip to content

Commit 40603f5

Browse files
committed
Use Rack::Utils for serialization/deserialization of deep query parameters
1 parent 0d34dbc commit 40603f5

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/rspec_api_documentation.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
require 'active_support/inflector'
33
require 'cgi'
44
require 'json'
5-
require 'active_support/core_ext/object/to_query'
65

76
module RspecApiDocumentation
87
extend ActiveSupport::Autoload

lib/rspec_api_documentation/dsl/endpoint.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
require 'rspec/core/formatters/base_formatter'
2+
require 'rack/utils'
3+
require 'rack/test/utils'
24

35
module RspecApiDocumentation::DSL
46
module Endpoint
57
extend ActiveSupport::Concern
8+
include Rack::Test::Utils
69

710
delegate :response_headers, :status, :response_status, :response_body, :to => :client
811

@@ -45,7 +48,7 @@ def do_request(extra_params = {})
4548
end
4649

4750
def query_string
48-
(params || {}).to_query
51+
build_nested_query(params || {})
4952
end
5053

5154
def params

spec/dsl_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@
389389

390390
example "parsed properly" do
391391
client.should_receive(:get).with do |path, data, headers|
392-
Addressable::URI.parse(path).query_values.should eq({"id_eq"=>['1', '2']})
392+
Rack::Utils.parse_nested_query(path.gsub('/orders?', '')).should eq({"id_eq"=>['1', '2']})
393393
end
394394
do_request
395395
end
@@ -403,7 +403,7 @@
403403

404404
example "parsed properly" do
405405
client.should_receive(:get).with do |path, data, headers|
406-
Addressable::URI.parse(path).query_values.should eq({
406+
Rack::Utils.parse_nested_query(path.gsub('/orders?', '')).should eq({
407407
"search" => { "within_id" => {"first" => '1', "last" => '10', "exclude" => ['3','5','7']}}
408408
})
409409
end

0 commit comments

Comments
 (0)