lib/lookout/rack/test/cucumber/general_steps.rb in lookout-rack-test-2.3.1 vs lib/lookout/rack/test/cucumber/general_steps.rb in lookout-rack-test-3.0.0

- old
+ new

@@ -14,16 +14,26 @@ verb = verb.downcase.to_sym headers = template_vars['headers'] || {} send(verb, render_string(url), options, headers) end -When /^I (GET|PUT|POST|PATCH|DELETE) to "(.*?)" with the JSON:$/ do |verb, url, body| +When /^I (GET|PUT|POST|PATCH) to "(.*?)" with the JSON:$/ do |verb, url, body| verb = verb.downcase.to_sym headers = template_vars['headers'] || {} send(verb, render_string(url), render_string(body), headers) end +When /^I DELETE to "(.*?)" with the JSON:$/ do |url, body| + # Rack::Test lost the ability to provide a body for delete + # requests. Until https://github.com/rack-test/rack-test/issues/200 + # is resolved, work around this + env = {:method => :delete, + :input => render_string(body), + }.merge(template_vars['headers'] || {}) + request render_string(url), env +end + Then /^the response (should be|is) (\d+)$/ do |verb, code| expect(last_response.status).to eq(code), "expected #{code} got #{last_response.status} \n\n #{last_response.body} " end @@ -49,6 +59,6 @@ end When /^I (PUT|POST) a file to "(.*?)"$/ do |verb, url| verb = verb.downcase.to_sym send(verb, render_string(url), "some file", template_vars['headers'] || {}) -end \ No newline at end of file +end