check json body for tests
This commit is contained in:
parent
438d20884a
commit
5593b546d8
@ -27,10 +27,12 @@ When(/^I send POST '(.*)' query with params '(.*)'$/) do |path, params|
|
|||||||
end
|
end
|
||||||
|
|
||||||
When(/^I send POST '(.*)' query with JSON body$/) do |path, body|
|
When(/^I send POST '(.*)' query with JSON body$/) do |path, body|
|
||||||
|
JSON.parse(body) unless body.strip.empty?
|
||||||
res = post_body(path, body, DEFAULT_HEADERS)
|
res = post_body(path, body, DEFAULT_HEADERS)
|
||||||
end
|
end
|
||||||
|
|
||||||
When(/^I send POST '(.*)' query with JSON body without header '(.*)'$/) do |path, hs, body|
|
When(/^I send POST '(.*)' query with JSON body without header '(.*)'$/) do |path, hs, body|
|
||||||
|
JSON.parse(body) unless body.strip.empty?
|
||||||
headers = DEFAULT_HEADERS.select{|h, v| h != hs}
|
headers = DEFAULT_HEADERS.select{|h, v| h != hs}
|
||||||
res = post_body(path, body, headers)
|
res = post_body(path, body, headers)
|
||||||
end
|
end
|
||||||
@ -40,6 +42,7 @@ When(/^I send DELETE '(.*)' query$/) do |path|
|
|||||||
end
|
end
|
||||||
|
|
||||||
When(/^I send DELETE '(.*)' query with JSON body$/) do |path, body|
|
When(/^I send DELETE '(.*)' query with JSON body$/) do |path, body|
|
||||||
|
JSON.parse(body) unless body.strip.empty?
|
||||||
res = delete_body(path, body, DEFAULT_HEADERS)
|
res = delete_body(path, body, DEFAULT_HEADERS)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -50,6 +53,7 @@ When(/^I send DELETE '(.*)' query without header '(.*)'$/) do |path, hs|
|
|||||||
end
|
end
|
||||||
|
|
||||||
When(/^I send DELETE '(.*)' query with JSON body without header '(.*)'$/) do |path, hs, body|
|
When(/^I send DELETE '(.*)' query with JSON body without header '(.*)'$/) do |path, hs, body|
|
||||||
|
JSON.parse(body) unless body.strip.empty?
|
||||||
headers = DEFAULT_HEADERS.select{|h, v| h != hs}
|
headers = DEFAULT_HEADERS.select{|h, v| h != hs}
|
||||||
res = delete_body(path, body, headers)
|
res = delete_body(path, body, headers)
|
||||||
end
|
end
|
||||||
@ -63,6 +67,7 @@ When(/^I send PUT '(.*)' query with body$/) do |path, body|
|
|||||||
end
|
end
|
||||||
|
|
||||||
When(/^I send PUT '(.*)' query with JSON body$/) do |path, body|
|
When(/^I send PUT '(.*)' query with JSON body$/) do |path, body|
|
||||||
|
JSON.parse(body) unless body.strip.empty?
|
||||||
res = put_body(path, body, DEFAULT_HEADERS)
|
res = put_body(path, body, DEFAULT_HEADERS)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -76,6 +81,7 @@ When(/^I send PUT '(.*)' query with body without header '(.*)'$/) do |path, hs,
|
|||||||
end
|
end
|
||||||
|
|
||||||
When(/^I send PUT '(.*)' query with JSON body without header '(.*)'$/) do |path, hs, body|
|
When(/^I send PUT '(.*)' query with JSON body without header '(.*)'$/) do |path, hs, body|
|
||||||
|
JSON.parse(body) unless body.strip.empty?
|
||||||
headers = DEFAULT_HEADERS.select{|h, v| h != hs}
|
headers = DEFAULT_HEADERS.select{|h, v| h != hs}
|
||||||
res = put_body(path, body, headers)
|
res = put_body(path, body, headers)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user