From 5593b546d836d365fd66b5ba08f173306ddd2c79 Mon Sep 17 00:00:00 2001 From: amartynov Date: Wed, 9 Jul 2014 12:36:06 +0400 Subject: [PATCH] check json body for tests --- .../features/step_definitions/http_queries_steps.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/devops-service/features/step_definitions/http_queries_steps.rb b/devops-service/features/step_definitions/http_queries_steps.rb index 146f3c9..fd8936c 100644 --- a/devops-service/features/step_definitions/http_queries_steps.rb +++ b/devops-service/features/step_definitions/http_queries_steps.rb @@ -27,10 +27,12 @@ When(/^I send POST '(.*)' query with params '(.*)'$/) do |path, params| end 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) end 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} res = post_body(path, body, headers) end @@ -40,6 +42,7 @@ When(/^I send DELETE '(.*)' query$/) do |path| end 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) end @@ -50,6 +53,7 @@ When(/^I send DELETE '(.*)' query without header '(.*)'$/) do |path, hs| end 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} res = delete_body(path, body, headers) end @@ -63,6 +67,7 @@ When(/^I send PUT '(.*)' query with body$/) do |path, body| end 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) end @@ -76,6 +81,7 @@ When(/^I send PUT '(.*)' query with body without header '(.*)'$/) do |path, hs, end 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} res = put_body(path, body, headers) end