From 67a947287b765b557cd9016250d4099ce871b8b5 Mon Sep 17 00:00:00 2001 From: Kevin Gatchalian Date: Tue, 12 Sep 2017 13:58:12 +0800 Subject: [PATCH] Update steps.rb to resolve issues #8 and #19 -Add a custom step to clear cache on demand from feature file -POST with json file --- lib/cucumber-api/steps.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/cucumber-api/steps.rb b/lib/cucumber-api/steps.rb index 4ea9345..f7bf6d5 100644 --- a/lib/cucumber-api/steps.rb +++ b/lib/cucumber-api/steps.rb @@ -2,12 +2,15 @@ require 'cucumber-api/helpers' require 'rest-client' require 'json-schema' +require 'json' if ENV['cucumber_api_verbose'] == 'true' RestClient.log = 'stdout' end -$cache = {} +Given(/^I clear the response cache$/) do + $cache = {} +end Given(/^I send and accept JSON$/) do steps %Q{ @@ -77,7 +80,7 @@ when 'yml' @body = YAML.load File.open(path) when 'json' - @body = JSON.parse File.read(path) + @body = JSON.dump(JSON.parse File.read(path)) else raise %/Unsupported file type: '#{path}'/ end