metaforce 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -28,6 +28,19 @@ client = Metaforce.new :username => 'username',
28
28
  :security_token => 'security token'
29
29
  ```
30
30
 
31
+ Or you can specify the username, password and security token with environment
32
+ variables:
33
+
34
+ ```bash
35
+ export SALESFORCE_USERNAME="username"
36
+ export SALESFORCE_PASSWORD="password"
37
+ export SALESFORCE_SECURITY_TOKEN="security token"
38
+ ```
39
+
40
+ ```ruby
41
+ client = Metaforce.new
42
+ ```
43
+
31
44
  #### Asynchronous Tasks
32
45
 
33
46
  Some calls to the SOAP API's are performed asynchronously (such as deployments),
@@ -23,7 +23,10 @@ module Metaforce
23
23
 
24
24
  # Performs a login and retrurns the session
25
25
  def login(options={})
26
- Login.new(options.delete(:username), options.delete(:password), options.delete(:security_token)).login
26
+ username = options.fetch(:username, ENV['SALESFORCE_USERNAME'])
27
+ password = options.fetch(:password, ENV['SALESFORCE_PASSWORD'])
28
+ security_token = options.fetch(:security_token, ENV['SALESFORCE_SECURITY_TOKEN'])
29
+ Login.new(username, password, security_token).login
27
30
  end
28
31
  end
29
32
  end
@@ -1,3 +1,3 @@
1
1
  module Metaforce
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
@@ -11,10 +11,32 @@ describe Metaforce do
11
11
  describe '#login' do
12
12
  let(:args) { {:username => 'foo', :password => 'foobar', :security_token => 'whizbang'} }
13
13
 
14
- it 'proxies the login call' do
15
- Metaforce::Login.should_receive(:new).with('foo', 'foobar', 'whizbang').and_call_original
16
- Metaforce::Login.any_instance.should_receive(:login)
17
- described_class.login args
14
+ context 'when environment variables are not defined' do
15
+ it 'proxies the login call' do
16
+ Metaforce::Login.should_receive(:new).with('foo', 'foobar', 'whizbang').and_call_original
17
+ Metaforce::Login.any_instance.should_receive(:login)
18
+ described_class.login args
19
+ end
20
+ end
21
+
22
+ context 'when environment variables are defined' do
23
+ before do
24
+ ENV['SALESFORCE_USERNAME'] = args[:username]
25
+ ENV['SALESFORCE_PASSWORD'] = args[:password]
26
+ ENV['SALESFORCE_SECURITY_TOKEN'] = args[:security_token]
27
+ end
28
+
29
+ after do
30
+ ENV.delete('SALESFORCE_USERNAME')
31
+ ENV.delete('SALESFORCE_PASSWORD')
32
+ ENV.delete('SALESFORCE_SECURITY_TOKEN')
33
+ end
34
+
35
+ it 'proxies the login call' do
36
+ Metaforce::Login.should_receive(:new).with('foo', 'foobar', 'whizbang').and_call_original
37
+ Metaforce::Login.any_instance.should_receive(:login)
38
+ described_class.login
39
+ end
18
40
  end
19
41
  end
20
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metaforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-24 00:00:00.000000000 Z
13
+ date: 2012-12-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: savon