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)
|
if klass.is_a?(Class)
|
||||||
middleware = klass
|
middleware = klass
|
||||||
else
|
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
|
end
|
||||||
|
|
||||||
use middleware, *args, &block
|
use middleware, *args, &block
|
||||||
|
|
|
@ -16,5 +16,13 @@ describe OmniAuth::Builder do
|
||||||
provider ::ExampleClass
|
provider ::ExampleClass
|
||||||
end }.should_not raise_error
|
end }.should_not raise_error
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue