Adds better error for missing provider. Closes #536
This commit is contained in:
parent
c98b6e0637
commit
4af02425f8
|
@ -19,7 +19,11 @@ module OmniAuth
|
|||
if klass.is_a?(Class)
|
||||
middleware = klass
|
||||
else
|
||||
middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
|
||||
begin
|
||||
middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
|
||||
rescue NameError
|
||||
raise LoadError, "Could not find matching strategy for #{klass.inspect}. You may need to install an additional gem (such as omniauth-#{klass})."
|
||||
end
|
||||
end
|
||||
|
||||
use middleware, *args, &block
|
||||
|
|
|
@ -16,5 +16,13 @@ describe OmniAuth::Builder do
|
|||
provider ::ExampleClass
|
||||
end }.should_not raise_error
|
||||
end
|
||||
|
||||
it "should raise a helpful LoadError messgae if it can't find the class" do
|
||||
expect {
|
||||
OmniAuth::Builder.new(nil) do
|
||||
provider :lorax
|
||||
end
|
||||
}.to raise_error(LoadError, "Could not find matching strategy for :lorax. You may need to install an additional gem (such as omniauth-lorax).")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue