diff --git a/spec/driver_rendering_spec.rb b/spec/driver_rendering_spec.rb
index c9ff9eb..f3794dc 100644
--- a/spec/driver_rendering_spec.rb
+++ b/spec/driver_rendering_spec.rb
@@ -6,18 +6,13 @@ describe Capybara::Webkit::Driver, "rendering an image" do
include AppRunner
let(:driver) do
- driver_for_app do |env|
- body = <<-HTML
-
-
+
+
+ HTML
end
before(:each) do
diff --git a/spec/driver_spec.rb b/spec/driver_spec.rb
index 4167697..e806eaa 100644
--- a/spec/driver_spec.rb
+++ b/spec/driver_spec.rb
@@ -7,37 +7,37 @@ describe Capybara::Webkit::Driver do
context "iframe app" do
let(:driver) do
- driver_for_app do |env|
- params = ::Rack::Utils.parse_query(env['QUERY_STRING'])
- if params["iframe"] == "true"
- # We are in an iframe request.
- p_id = "farewell"
- msg = "goodbye"
- iframe = nil
- else
- # We are not in an iframe request and need to make an iframe!
- p_id = "greeting"
- msg = "hello"
- iframe = ""
+ driver_for_app do
+ get "/" do
+ if in_iframe_request?
+ p_id = "farewell"
+ msg = "goodbye"
+ iframe = nil
+ else
+ p_id = "greeting"
+ msg = "hello"
+ iframe = ""
+ end
+ <<-HTML
+
+
+
+
+
+ #{iframe}
+
+
+
+ HTML
+ end
+
+ def in_iframe_request?
+ params[:iframe] == "true"
end
- body = <<-HTML
-
-
-
-
-
- #{iframe}
-
-
-
- HTML
- [200,
- { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
- [body]]
end
end
@@ -108,43 +108,37 @@ describe Capybara::Webkit::Driver do
context "error iframe app" do
let(:driver) do
- driver_for_app do |env|
- case env["PATH_INFO"]
- when "/inner-not-found"
- [404, {}, []]
- when "/outer"
- body = <<-HTML
+ driver_for_app do
+ get "/inner-not-found" do
+ invalid_response
+ end
+
+ get "/" do
+ <<-HTML
-
+
HTML
- [200,
- { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
- [body]]
- else
- body = ""
- return [200, {'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s}, [body]]
end
end
end
- before { driver.visit("/") }
-
it "raises error whose message references the actual missing url" do
- expect { driver.visit("/outer") }.to raise_error(Capybara::Webkit::InvalidResponseError, /inner-not-found/)
+ expect { driver.visit("/") }.to raise_error(Capybara::Webkit::InvalidResponseError, /inner-not-found/)
end
end
context "redirect app" do
let(:driver) do
- driver_for_app do |env|
- if env['PATH_INFO'] == '/target'
- content_type = "
#{env['CONTENT_TYPE']}
"
- [200, {"Content-Type" => "text/html", "Content-Length" => content_type.length.to_s}, [content_type]]
- elsif env['PATH_INFO'] == '/form'
- body = <<-HTML
+ driver_for_app do
+ get '/target' do
+ "
#{env['CONTENT_TYPE']}
"
+ end
+
+ get '/form' do
+ <<-HTML
-
- HTML
- [200,
- { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
- [body]]
- end
+ driver_for_html(<<-HTML)
+
+
+
+ HTML
end
before { driver.visit("/") }
@@ -627,34 +607,28 @@ describe Capybara::Webkit::Driver do
context "dom events" do
let(:driver) do
- driver_for_app do |env|
- body = <<-HTML
+ driver_for_html(<<-HTML)
+
+ Link
+
+
-
- HTML
- [200,
- { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
- [body]]
- end
+ var elements = document.getElementsByClassName("watch");
+ for (var i = 0; i < elements.length; i++) {
+ var element = elements[i];
+ element.addEventListener("mousedown", recordEvent);
+ element.addEventListener("mouseup", recordEvent);
+ element.addEventListener("click", recordEvent);
+ }
+
+