Permalink
Browse files

added specs for Node#submit and fixed parameter problem

  • Loading branch information...
1 parent 21f4b84 commit d07cf3db4d73470da881fde9e80b16395f297570 @niklasb niklasb committed with halogenandtoast Oct 22, 2011
Showing with 31 additions and 1 deletion.
  1. +1 −1 lib/capybara/driver/webkit/node.rb
  2. +30 −0 spec/driver_spec.rb
View
2 lib/capybara/driver/webkit/node.rb
@@ -77,7 +77,7 @@ def path
invoke "path"
end
- def submit(opts)
+ def submit(opts = {})
invoke "submit"
end
View
30 spec/driver_spec.rb
@@ -1182,4 +1182,34 @@ def set_automatic_reload(value)
end
end
end
+
+ context "form app with server-side handler" do
+ before(:all) do
+ @app = lambda do |env|
+ if env["REQUEST_METHOD"] == "POST"
+ body = "<html><body><p>Congrats!</p></body></html>"
+ else
+ body = <<-HTML
+ <html>
+ <head><title>Form</title>
+ <body>
+ <form action="/" method="POST">
+ <input type="hidden" name="abc" value="123" />
+ <input type="submit" value="Submit" />
+ </form>
+ </body>
+ </html>
+ HTML
+ end
+ [200,
+ { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
+ [body]]
+ end
+ end
+
+ it "submits a form without clicking" do
+ subject.find("//form")[0].submit
+ subject.body.should include "Congrats"
+ end
+ end
end

0 comments on commit d07cf3d

Please sign in to comment.