warn when the app passed doesnt respond to #call

This commit is contained in:
Thomas Walpole 2016-12-10 10:33:25 -08:00
parent ad439ba37f
commit 9fc3ad9735
2 changed files with 11 additions and 0 deletions

View File

@ -67,6 +67,7 @@ module Capybara
attr_accessor :synchronized
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
@app = app
if Capybara.run_server and @app and driver.needs_server?

10
spec/session_spec.rb Normal file
View File

@ -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