Skip to content
Browse files

Resize window spec uses AppRunner

  • Loading branch information...
1 parent c1682d2 commit 3bc96bcb19ffb39164a7ad86d01aaf3b6fd3a75c @mhoran mhoran committed Nov 17, 2012
Showing with 29 additions and 40 deletions.
  1. +29 −40 spec/driver_resize_window_spec.rb
View
69 spec/driver_resize_window_spec.rb
@@ -2,58 +2,47 @@
require 'capybara/webkit/driver'
describe Capybara::Webkit::Driver, "#resize_window(width, height)" do
-
- before(:all) do
- app = lambda do |env|
- body = <<-HTML
- <html>
- <body>
- <h1 id="dimentions">UNKNOWN</h1>
-
- <script>
- window.onload = window.onresize = function(){
- document.getElementById("dimentions").innerHTML = "[" + window.innerWidth + "x" + window.innerHeight + "]";
- };
- </script>
-
- </body>
- </html>
- HTML
-
- [
- 200,
- { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
- [body]
- ]
- end
-
- @driver = Capybara::Webkit::Driver.new(app, :browser => $webkit_browser)
+ include AppRunner
+
+ let(:driver) do
+ driver_for_html(<<-HTML)
+ <html>
+ <body>
+ <h1 id="dimentions">UNKNOWN</h1>
+
+ <script>
+ window.onload = window.onresize = function(){
+ document.getElementById("dimentions").innerHTML = "[" + window.innerWidth + "x" + window.innerHeight + "]";
+ };
+ </script>
+
+ </body>
+ </html>
+ HTML
end
DEFAULT_DIMENTIONS = "[1680x1050]"
it "resizes the window to the specified size" do
- @driver.visit("/")
+ driver.visit("#{AppRunner.app_host}/")
- @driver.resize_window(800, 600)
- @driver.html.should include("[800x600]")
+ driver.resize_window(800, 600)
+ driver.html.should include("[800x600]")
- @driver.resize_window(300, 100)
- @driver.html.should include("[300x100]")
+ driver.resize_window(300, 100)
+ driver.html.should include("[300x100]")
end
it "resizes the window to the specified size even before the document has loaded" do
- @driver.resize_window(800, 600)
- @driver.visit("/")
- @driver.html.should include("[800x600]")
+ driver.resize_window(800, 600)
+ driver.visit("#{AppRunner.app_host}/")
+ driver.html.should include("[800x600]")
end
it "resets the window to the default size when the driver is reset" do
- @driver.resize_window(800, 600)
- @driver.reset!
- @driver.visit("/")
- @driver.html.should include(DEFAULT_DIMENTIONS)
+ driver.resize_window(800, 600)
+ driver.reset!
+ driver.visit("#{AppRunner.app_host}/")
+ driver.html.should include(DEFAULT_DIMENTIONS)
end
-
- after(:all) { @driver.reset! }
end

0 comments on commit 3bc96bc

Please sign in to comment.
Something went wrong with that request. Please try again.