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={})
|
||||
@app = app
|
||||
@options = options
|
||||
@rack_server = Capybara::Server.new(@app)
|
||||
@rack_server.boot if Capybara.run_server
|
||||
@browser = options[:browser] || Browser.new(Connection.new(options))
|
||||
end
|
||||
|
||||
|
@ -32,7 +30,7 @@ module Capybara::Webkit
|
|||
end
|
||||
|
||||
def visit(path)
|
||||
browser.visit(url(path))
|
||||
browser.visit(path)
|
||||
end
|
||||
|
||||
def find(query)
|
||||
|
@ -147,6 +145,10 @@ module Capybara::Webkit
|
|||
true
|
||||
end
|
||||
|
||||
def needs_server?
|
||||
true
|
||||
end
|
||||
|
||||
def wait_until(*args)
|
||||
end
|
||||
|
||||
|
@ -165,10 +167,6 @@ module Capybara::Webkit
|
|||
browser.render path, options[:width], options[:height]
|
||||
end
|
||||
|
||||
def server_port
|
||||
@rack_server.port
|
||||
end
|
||||
|
||||
def cookies
|
||||
@cookie_jar ||= CookieJar.new(browser)
|
||||
end
|
||||
|
@ -178,9 +176,5 @@ module Capybara::Webkit
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
def url(path)
|
||||
@rack_server.url(path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'capybara/webkit/connection'
|
|||
|
||||
describe Capybara::Webkit::Connection 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 1
|
||||
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
|
||||
# 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'
|
||||
|
||||
|
@ -51,17 +51,6 @@ module AppRunner
|
|||
def self.included(example_group)
|
||||
example_group.class_eval do
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue