DEFAULT_HEADERS = { "REMOTE_USER" => "user_for_testing", 'Content-Type' => 'application/json', 'Accept' => 'application/json' } When(/^I send GET '(.*)' query$/) do |path| get(path, {}, DEFAULT_HEADERS) end When(/^I send GET '(.*)' query without headers '(.*)'$/) do |path, hs| buf = hs.split(",").map{|e| e.strip} headers = {} DEFAULT_HEADERS.each{|h, v| headers[h] = v unless buf.include?(h)} puts headers get(path, {}, headers) end When(/^I send POST '(.*)' query with params '(.*)'$/) do |path, params| if params == '' p = Hash.new else p = JSON.parse params end res = post(path, p, DEFAULT_HEADERS) end When(/^I send DELETE '(.*)' query$/) do |path| delete(path, {}, DEFAULT_HEADERS) end Then(/^response should be '(\d+)'$/) do |code| assert(code.to_i == last_response.status, "Status is not #{code}, it is #{last_response.status}") end Then(/^the Content\-Type header should include 'application\/json'$/) do assert last_response.header.contenttype.include?("application/json"), "Response has no header 'Content-Type' with 'application/json'" end