lib/capybara/httpclient_json/driver.rb in capybara-json-0.3.0 vs lib/capybara/httpclient_json/driver.rb in capybara-json-0.4.0
- old
+ new
@@ -56,10 +56,16 @@
json = MultiJson.dump(json) unless json.is_a?(String)
headers['Content-Type'] = "application/json; charset=#{json.encoding.to_s.downcase}"
process :post, url, json, headers, options[:follow_redirect]
end
+ def patch(url, json, headers = {})
+ json = MultiJson.dump(json) unless json.is_a?(String)
+ headers['Content-Type'] = "application/json; charset=#{json.encoding.to_s.downcase}"
+ process :patch, url, json, headers, options[:follow_redirect]
+ end
+
def put(url, json, headers = {})
json = MultiJson.dump(json) unless json.is_a?(String)
headers['Content-Type'] = "application/json; charset=#{json.encoding.to_s.downcase}"
process :put, url, json, headers
end
@@ -74,10 +80,10 @@
handle_error { #{method}(url, params, env) }
end
DEF
end
- %w[ post put ].each do |method|
+ %w[ post put patch ].each do |method|
class_eval %{
def #{method}!(url, json, headers = {})
handle_error { #{method}(url, json, headers) }
end
}