Skip to content

Commit

Permalink
Add spec to verify deep_merge functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmestad committed Dec 8, 2014
1 parent 608da0c commit 09ccb97
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rspec_api_documentation/dsl/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def do_request(extra_params = {})
if method == :get && !query_string.blank?
path_or_query += "?#{query_string}"
else
if respond_to?(:raw_post)
if respond_to?(:raw_post)
params_or_body = raw_post
else
formatter = RspecApiDocumentation.configuration.post_body_formatter
Expand Down Expand Up @@ -128,6 +128,7 @@ def rspec_api_documentation_client
def extra_params
return {} if @extra_params.nil?
@extra_params.inject({}) do |h, (k, v)|
v = v.is_a?(Hash) ? v.stringify_keys : v
h[k.to_s] = v
h
end
Expand Down
14 changes: 14 additions & 0 deletions spec/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@
context "auto request" do
post "/orders" do
parameter :order_type, "Type of order"
parameter :amount, "Amount of order", scope: :order
parameter :name, "Name of order", scope: :order


context "no extra params" do
before do
Expand All @@ -382,6 +385,17 @@

example_request "should take an optional parameter hash", :order_type => "big"
end

context "extra options for do_request with scoped hash" do
before do
expect(client).to receive(:post).with("/orders", {"order_type" => "big", "order" => {"amount" => "19.99", "name" => "Friday Order"}}, nil)
end

let(:amount) { '19.99' }
let(:name) { 'Monday Order' }

example_request "should deep merge the optional parameter hash", {:order_type => 'big', :order => {:name => 'Friday Order'}}
end
end
end

Expand Down

0 comments on commit 09ccb97

Please sign in to comment.