Session is responsible for starting server
This commit is contained in:
parent
dc5e0325c5
commit
61a6561d62
|
@ -14,8 +14,6 @@ module Capybara::Webkit
|
||||||
def initialize(app, options={})
|
def initialize(app, options={})
|
||||||
@app = app
|
@app = app
|
||||||
@options = options
|
@options = options
|
||||||
@rack_server = Capybara::Server.new(@app)
|
|
||||||
@rack_server.boot if Capybara.run_server
|
|
||||||
@browser = options[:browser] || Browser.new(Connection.new(options))
|
@browser = options[:browser] || Browser.new(Connection.new(options))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,7 +30,7 @@ module Capybara::Webkit
|
||||||
end
|
end
|
||||||
|
|
||||||
def visit(path)
|
def visit(path)
|
||||||
browser.visit(url(path))
|
browser.visit(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def find(query)
|
def find(query)
|
||||||
|
@ -147,6 +145,10 @@ module Capybara::Webkit
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def needs_server?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def wait_until(*args)
|
def wait_until(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -165,10 +167,6 @@ module Capybara::Webkit
|
||||||
browser.render path, options[:width], options[:height]
|
browser.render path, options[:width], options[:height]
|
||||||
end
|
end
|
||||||
|
|
||||||
def server_port
|
|
||||||
@rack_server.port
|
|
||||||
end
|
|
||||||
|
|
||||||
def cookies
|
def cookies
|
||||||
@cookie_jar ||= CookieJar.new(browser)
|
@cookie_jar ||= CookieJar.new(browser)
|
||||||
end
|
end
|
||||||
|
@ -178,9 +176,5 @@ module Capybara::Webkit
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def url(path)
|
|
||||||
@rack_server.url(path)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'capybara/webkit/connection'
|
||||||
|
|
||||||
describe Capybara::Webkit::Connection do
|
describe Capybara::Webkit::Connection do
|
||||||
it "boots a server to talk to" do
|
it "boots a server to talk to" do
|
||||||
url = @rack_server.url("/")
|
url = "http://#{@rack_server.host}:#{@rack_server.port}/"
|
||||||
connection.puts "Visit"
|
connection.puts "Visit"
|
||||||
connection.puts 1
|
connection.puts 1
|
||||||
connection.puts url.to_s.bytesize
|
connection.puts url.to_s.bytesize
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Boots a single Capybara::Server for a Rack application that delegates to another, singleton Rack
|
# Boots a single Capybara::Server for a Rack application that delegates to another, singleton Rack
|
||||||
# application that can be configured for each spec. Also configures Capybara to use that server.
|
# application that can be configured for each spec.
|
||||||
|
|
||||||
require 'sinatra/base'
|
require 'sinatra/base'
|
||||||
|
|
||||||
|
@ -51,17 +51,6 @@ module AppRunner
|
||||||
def self.included(example_group)
|
def self.included(example_group)
|
||||||
example_group.class_eval do
|
example_group.class_eval do
|
||||||
before { AppRunner.reset }
|
before { AppRunner.reset }
|
||||||
|
|
||||||
around do |example|
|
|
||||||
Capybara.run_server = false
|
|
||||||
Capybara.app_host = AppRunner.app_host
|
|
||||||
begin
|
|
||||||
example.run
|
|
||||||
ensure
|
|
||||||
Capybara.run_server = true
|
|
||||||
Capybara.app_host = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue