Skip to content

Commit

Permalink
Only check for attached nodes when reloading is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jferris committed Sep 30, 2011
1 parent 5843e56 commit 36e13f7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/capybara/driver/webkit/node.rb
Expand Up @@ -88,13 +88,17 @@ def find(xpath)
end

def invoke(name, *args)
if attached?
if allow_unattached_nodes? || attached?
browser.command "Node", name, native, *args
else
raise Capybara::Driver::Webkit::NodeNotAttachedError
end
end

def allow_unattached_nodes?
!Capybara.automatic_reload
end

def attached?
browser.command("Node", "isAttached", native) == "true"
end
Expand Down
26 changes: 26 additions & 0 deletions spec/driver_spec.rb
Expand Up @@ -981,4 +981,30 @@ def echoed_cookie
driver_with_debugger.find("//*[@id='parent']")
end
end

context "remove node app" do
before(:all) do
@app = lambda do |env|
body = <<-HTML
<html>
<div id="parent">
<p id="removeMe">Hello</p>
</div>
</html>
HTML
[200,
{ 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
[body]]
end
end

before { Capybara.automatic_reload = false }
after { Capybara.automatic_reload = true }

it "allows removed nodes when reloading is disabled" do
node = subject.find("//p[@id='removeMe']").first
subject.evaluate_script("document.getElementById('parent').innerHTML = 'Magic'")
node.text.should == 'Hello'
end
end
end

0 comments on commit 36e13f7

Please sign in to comment.