Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Attempt to write a failing spec for PATCH bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
jferris committed Apr 9, 2015
1 parent 61403a2 commit 6b6a2e1
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions spec/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
describe Capybara::Webkit::Driver do
include AppRunner

def visit(url, driver=driver)
driver.visit("#{AppRunner.app_host}#{url}")
def visit(url, visiting_driver=driver)
visiting_driver.visit("#{AppRunner.app_host}#{url}")
end

context "iframe app" do
Expand Down Expand Up @@ -2907,6 +2907,41 @@ def which_for(character)
end
end

context "HTTP PATCH" do
let(:driver) do
driver_for_app do
get "/" do
<<-HTML
<script type="text/javascript">
function makeRequest() {
var xhr = new XMLHttpRequest();
xhr.open('PATCH', '/', false);
xhr.setRequestHeader('Content-Type', 'text/plain');
xhr.send('expectedBody');
var resultNode = document.getElementById("result");
resultNode.innerHTML = xhr.response;
console.log(xhr.response);
return false;
}
</script>
<a href="javascript:makeRequest()">Make Request</a>
<p id="result">GET</p>
HTML
end

patch "/" do
"#{request.request_method}:#{request.body.read}"
end
end
end

it "sends a request body" do
visit "/"
driver.find_xpath("//a").first.click
expect(driver.find_xpath("//p").first.text).to eq("PATCH:expectedBody")
end
end

context "version" do
let(:driver) do
driver_for_html(<<-HTML)
Expand Down

0 comments on commit 6b6a2e1

Please sign in to comment.