Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow client app_id and app_secret to be set globally as environment …

…variables
  • Loading branch information...
commit 780da651cd0a7419b90f4f25ddfc97d967e4837e 1 parent 6253565
@timcraft timcraft authored
Showing with 9 additions and 2 deletions.
  1. +2 −2 lib/gocardless/client.rb
  2. +7 −0 spec/client_spec.rb
View
4 lib/gocardless/client.rb
@@ -30,8 +30,8 @@ def api_url
def initialize(args = {})
Utils.symbolize_keys! args
- @app_id = args[:app_id]
- @app_secret = args[:app_secret]
+ @app_id = args.fetch(:app_id) { ENV['GOCARDLESS_APP_ID'] }
+ @app_secret = args.fetch(:app_secret) { ENV['GOCARDLESS_APP_SECRET'] }
raise ClientError.new("You must provide an app_id") unless @app_id
raise ClientError.new("You must provide an app_secret") unless @app_secret
View
7 spec/client_spec.rb
@@ -37,6 +37,13 @@
end.should raise_exception(GoCardless::ClientError)
end
+ it "does not raise an error if the credentials are provided as environment variables" do
+ ENV.expects(:[]).with('GOCARDLESS_APP_ID').returns(@app_id)
+ ENV.expects(:[]).with('GOCARDLESS_APP_SECRET').returns(@app_secret)
+
+ GoCardless::Client.new
+ end
+
it "sets a merchant id if it's given" do
client = GoCardless::Client.new({
:app_id => @app_id,
Please sign in to comment.
Something went wrong with that request. Please try again.