warn when the app passed doesnt respond to #call
This commit is contained in:
parent
ad439ba37f
commit
9fc3ad9735
|
@ -67,6 +67,7 @@ module Capybara
|
||||||
attr_accessor :synchronized
|
attr_accessor :synchronized
|
||||||
|
|
||||||
def initialize(mode, app=nil)
|
def initialize(mode, app=nil)
|
||||||
|
raise ArgumentError, "The second parameter to Session::new should be a rack app if passed." if app && !app.respond_to?(:call)
|
||||||
@mode = mode
|
@mode = mode
|
||||||
@app = app
|
@app = app
|
||||||
if Capybara.run_server and @app and driver.needs_server?
|
if Capybara.run_server and @app and driver.needs_server?
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
RSpec.describe Capybara::Session do
|
||||||
|
it "verifies a passed app is a rack app" do
|
||||||
|
expect do
|
||||||
|
Capybara::Session.new(:unknown, { random: "hash"})
|
||||||
|
end.to raise_error ArgumentError, "The second parameter to Session::new should be a rack app if passed."
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue