Sha256: 3aef3d9f8c7af567785b7a7c3de3898fbe85094989dba71f81c55b7cc05a3d7a
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
require File.expand_path("#{File.dirname(__FILE__)}/../../helper") describe SendgridToolkit::AbstractSendgridClient do before do backup_env end after do restore_env end describe "#initialize" do it "stores api credentials when passed in" do ENV['SMTP_USERNAME'] = "env_username" ENV['SMTP_PASSWORD'] = "env_apikey" @obj = SendgridToolkit::AbstractSendgridClient.new("username", "apikey") @obj.instance_variable_get("@api_user").should == "username" @obj.instance_variable_get("@api_key").should == "apikey" end it "resorts to environment variables when no credentials specified" do ENV['SMTP_USERNAME'] = "env_username" ENV['SMTP_PASSWORD'] = "env_apikey" @obj = SendgridToolkit::AbstractSendgridClient.new() @obj.instance_variable_get("@api_user").should == "env_username" @obj.instance_variable_get("@api_key").should == "env_apikey" end it "throws error when no credentials are found" do ENV['SMTP_USERNAME'] = nil ENV['SMTP_PASSWORD'] = nil lambda { @obj = SendgridToolkit::AbstractSendgridClient.new() }.should raise_error SendgridToolkit::NoAPIUserSpecified lambda { @obj = SendgridToolkit::AbstractSendgridClient.new(nil, "password") }.should raise_error SendgridToolkit::NoAPIUserSpecified lambda { @obj = SendgridToolkit::AbstractSendgridClient.new("user", nil) }.should raise_error SendgridToolkit::NoAPIKeySpecified end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sendgrid_toolkit-0.1.0 | spec/lib/sendgrid_toolkit/abstract_sendgrid_client_spec.rb |