salsalabs 0.1.0

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.
Files changed (52) hide show
  1. data/.gitignore +4 -0
  2. data/.rspec +1 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +9 -0
  6. data/Gemfile +2 -0
  7. data/README.md +27 -0
  8. data/Rakefile +49 -0
  9. data/lib/salsa_labs/api_response.rb +55 -0
  10. data/lib/salsa_labs/authentication_response.rb +44 -0
  11. data/lib/salsa_labs/configuration.rb +11 -0
  12. data/lib/salsa_labs/connection.rb +91 -0
  13. data/lib/salsa_labs/objects/distributed_event.rb +6 -0
  14. data/lib/salsa_labs/objects/donation.rb +6 -0
  15. data/lib/salsa_labs/objects/event.rb +6 -0
  16. data/lib/salsa_labs/objects/groups.rb +6 -0
  17. data/lib/salsa_labs/objects/supporter.rb +6 -0
  18. data/lib/salsa_labs/objects/supporter_action.rb +6 -0
  19. data/lib/salsa_labs/objects/supporter_action_comment.rb +6 -0
  20. data/lib/salsa_labs/objects/supporter_action_content.rb +6 -0
  21. data/lib/salsa_labs/objects/supporter_action_target.rb +6 -0
  22. data/lib/salsa_labs/objects/supporter_event.rb +6 -0
  23. data/lib/salsa_labs/objects/supporter_groups.rb +6 -0
  24. data/lib/salsa_labs/salsa_object.rb +74 -0
  25. data/lib/salsa_labs/salsa_request_overwrite.rb +30 -0
  26. data/lib/salsa_labs/save_response.rb +29 -0
  27. data/lib/salsa_labs/version.rb +3 -0
  28. data/lib/salsa_labs.rb +75 -0
  29. data/salsalabs.gemspec +28 -0
  30. data/spec/fixtures/auth_error.txt +14 -0
  31. data/spec/fixtures/auth_success.txt +18 -0
  32. data/spec/fixtures/expired_session.txt +12 -0
  33. data/spec/fixtures/malformed_response.txt +11 -0
  34. data/spec/fixtures/supporter/supporter_all.xml +135 -0
  35. data/spec/fixtures/supporter/supporter_count.xml +8 -0
  36. data/spec/fixtures/supporter/supporter_create.xml +1 -0
  37. data/spec/fixtures/supporter/supporter_get.xml +68 -0
  38. data/spec/fixtures/supporter/supporter_update.xml +1 -0
  39. data/spec/fixtures/supporters.txt +346 -0
  40. data/spec/integration/create_supporter_spec.rb +16 -0
  41. data/spec/integration/get_supporter_spec.rb +14 -0
  42. data/spec/spec_helper.rb +30 -0
  43. data/spec/support/fixtures.rb +7 -0
  44. data/spec/support/silence_warnings.rb +9 -0
  45. data/spec/unit/salsa_labs/api_response_spec.rb +82 -0
  46. data/spec/unit/salsa_labs/authentication_response_spec.rb +53 -0
  47. data/spec/unit/salsa_labs/configuration_spec.rb +33 -0
  48. data/spec/unit/salsa_labs/connection_spec.rb +84 -0
  49. data/spec/unit/salsa_labs/objects/supporter_spec.rb +62 -0
  50. data/spec/unit/salsa_labs/salsa_object_spec.rb +11 -0
  51. data/spec/unit/salsa_labs_spec.rb +36 -0
  52. metadata +283 -0
@@ -0,0 +1,9 @@
1
+ require 'stringio'
2
+
3
+ def silence_warnings
4
+ old_stderr = $stderr
5
+ $stderr = StringIO.new
6
+ yield
7
+ ensure
8
+ $stderr = old_stderr
9
+ end
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ describe SalsaLabs::ApiResponse do
4
+ # API Response Bodies
5
+ let(:api_success) { fixture_file 'supporters.txt' }
6
+ let(:expired_session) { fixture_file 'expired_session.txt' }
7
+ let(:malformed_response) { fixture_file 'malformed_response.txt' }
8
+ let(:api) { Faraday.new(url: 'https://sandbox.salsalabs.com/api') }
9
+
10
+ describe 'successful request' do
11
+ before do
12
+ stub_request(:get, 'https://sandbox.salsalabs.com/api/getObjects.sjs').
13
+ with(query: {object: 'supporter'}).
14
+ to_return(api_success)
15
+ @response = SalsaLabs::ApiResponse.new(api.get('getObjects.sjs', {object: 'supporter'}))
16
+ end
17
+
18
+ it 'is successful' do
19
+ expect(@response.successful?).to be_true
20
+ end
21
+
22
+ it 'does not need reauthentication' do
23
+ expect(@response.needs_reauthentication?).to be_false
24
+ end
25
+
26
+ it 'has a parsed body' do
27
+ expect(@response.body).to_not be_nil
28
+ expect(@response.body).to be_an_instance_of(::Nokogiri::XML::Document)
29
+ end
30
+
31
+ it 'has data' do
32
+ expect(@response.data).to_not be_nil
33
+ expect(@response.data).to be_an_instance_of(String)
34
+ end
35
+
36
+ it 'has no error' do
37
+ expect(@response.error_message).to be_nil
38
+ end
39
+ end
40
+
41
+ describe 'expired session' do
42
+ before do
43
+ stub_request(:get, 'https://sandbox.salsalabs.com/api/getObjects.sjs').
44
+ with(query: {object: 'supporter'}).
45
+ to_return(expired_session)
46
+ @response = SalsaLabs::ApiResponse.new(api.get('getObjects.sjs', {object: 'supporter'}))
47
+ end
48
+
49
+ it 'is not successful' do
50
+ expect(@response.successful?).to be_false
51
+ end
52
+
53
+ it 'needs reauthentication' do
54
+ expect(@response.needs_reauthentication?).to be_true
55
+ end
56
+
57
+ it 'has an error message that indicates the session has expired' do
58
+ expect(@response.error_message).to eq('There was a problem with your submission. Please authenticate in order to continue.')
59
+ end
60
+ end
61
+
62
+ describe 'unexpected response' do
63
+ before do
64
+ stub_request(:get, 'https://sandbox.salsalabs.com/api/getObjects.sjs').
65
+ with(query: {object: 'supporter'}).
66
+ to_return(malformed_response)
67
+ @response = SalsaLabs::ApiResponse.new(api.get('getObjects.sjs', {object: 'supporter'}))
68
+ end
69
+
70
+ it 'is not successful' do
71
+ expect(@response.successful?).to be_false
72
+ end
73
+
74
+ it 'does not need reauthentication' do
75
+ expect(@response.needs_reauthentication?).to be_false
76
+ end
77
+
78
+ it 'has an error message that indicates the session has expired' do
79
+ expect(@response.error_message).to eq('The response was not formatted as expected.')
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe SalsaLabs::AuthenticationResponse do
4
+ let(:email){ 'jane@doe.com' }
5
+ let(:password){ 'password' }
6
+
7
+ # API Response Bodies
8
+ let(:auth_success) { fixture_file 'auth_success.txt' }
9
+ let(:auth_failure) { fixture_file 'auth_error.txt' }
10
+ let(:api) { Faraday.new(url: 'https://sandbox.salsalabs.com/api') }
11
+
12
+ describe 'successful authentication' do
13
+ before do
14
+ stub_request(:get, 'https://sandbox.salsalabs.com/api/authenticate.sjs').
15
+ with(query: {email: email, password: password}).
16
+ to_return(auth_success)
17
+ @response = SalsaLabs::AuthenticationResponse.new(api.get('authenticate.sjs', {email: email, password: password}))
18
+ end
19
+
20
+ it 'knows that it is successful' do
21
+ expect(@response.successful?).to be_true
22
+ end
23
+
24
+ it "has a session cookie" do
25
+ expect(@response.session_cookies).to eq('JSESSIONID=A1737DC1330748B01456B3C269162AB6-n3; Path=/; Secure; HttpOnly, hqtab_2=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT, READONLY_Short_Name=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT, SRV=sandbox; path=/')
26
+ end
27
+
28
+ it "has no error" do
29
+ expect(@response.error_message).to be_nil
30
+ end
31
+ end
32
+
33
+ describe 'failed authentication' do
34
+ before do
35
+ stub_request(:get, 'https://sandbox.salsalabs.com/api/authenticate.sjs').
36
+ with(query: {email: email, password: password}).
37
+ to_return(auth_failure)
38
+ @response = SalsaLabs::AuthenticationResponse.new(api.get('authenticate.sjs', {email: email, password: password}))
39
+ end
40
+
41
+ it 'knows that it was not successful' do
42
+ expect(@response.successful?).to be_false
43
+ end
44
+
45
+ it "has no session cookie" do
46
+ expect(@response.session_cookies).to be_nil
47
+ end
48
+
49
+ it "has the response's headers" do
50
+ expect(@response.error_message).to eq('Invalid login, please try again.')
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe SalsaLabs::Configuration do
4
+ let(:config){ SalsaLabs::Configuration.new }
5
+
6
+ it 'is configurable' do
7
+ expect(config).to respond_to(:email=)
8
+ expect(config).to respond_to(:password=)
9
+ end
10
+
11
+ it 'is readable' do
12
+ expect(config).to respond_to(:email)
13
+ expect(config).to respond_to(:password)
14
+ end
15
+
16
+ it 'is invalid if email is blank' do
17
+ config.email = nil
18
+ config.password = 'password'
19
+ expect(config.valid?).to be_false
20
+ end
21
+
22
+ it 'is invalid if password is blank' do
23
+ config.email = 'jane@doe.com'
24
+ config.password = nil
25
+ expect(config.valid?).to be_false
26
+ end
27
+
28
+ it 'is valid if email and password are set' do
29
+ config.email = 'jane@doe.com'
30
+ config.password = 'password'
31
+ expect(config.valid?).to be_true
32
+ end
33
+ end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe SalsaLabs::Connection do
4
+ let(:email){ 'jane@doe.com' }
5
+ let(:password){ 'password' }
6
+ let(:connection){ SalsaLabs::Connection.new(email,password) }
7
+
8
+ # Response Object Doubles
9
+ let(:auth_response){ double('AuthenticationResponse', :successful? => true, :session_cookies => 'JSESSIONID=sessionid') }
10
+ let(:failed_auth_response){ double('AuthenticationResponse', :successful? => false, :error_message => 'failed auth') }
11
+ let(:api_response){ double('ApiResponse', :successful? => true, :data => 'result') }
12
+ let(:expired_api_response){ double('ApiResponse', :successful? => false, :needs_reauthentication? => true) }
13
+
14
+ before do
15
+ @auth_request = stub_request(:get, 'https://sandbox.salsalabs.com/api/authenticate.sjs').
16
+ with(query: {email: email, password: password})
17
+
18
+ @api_request = stub_request(:get, 'https://sandbox.salsalabs.com/api/getObjects.sjs').
19
+ with(query: {object: 'supporter'})
20
+ end
21
+
22
+ describe 'without an active session' do
23
+ before do
24
+ connection.stub(:authenticated?){ false }
25
+ end
26
+
27
+ it 'makes an authentication request first, then processes the request' do
28
+ expect(SalsaLabs::AuthenticationResponse).to receive(:new).and_return(auth_response)
29
+ expect(SalsaLabs::ApiResponse).to receive(:new).and_return(api_response)
30
+ connection.request('api/getObjects.sjs', {object: 'supporter'}) do |response|
31
+ expect(response).to eq('result')
32
+ end
33
+ expect(@auth_request).to have_been_requested
34
+ expect(@api_request).to have_been_requested
35
+ end
36
+ end
37
+
38
+ describe 'with active, authenticated session' do
39
+ before do
40
+ connection.stub(:authenticated?){ true }
41
+ end
42
+
43
+ it 'processes the request' do
44
+ expect(SalsaLabs::ApiResponse).to receive(:new).and_return(api_response)
45
+ connection.request('api/getObjects.sjs', {object: 'supporter'}) do |response|
46
+ expect(response).to eq('result')
47
+ end
48
+ expect(@auth_request).to_not have_been_requested
49
+ expect(@api_request).to have_been_requested
50
+ end
51
+ end
52
+
53
+ describe 'with an expired session' do
54
+ before do
55
+ connection.stub(:authenticated?){ true }
56
+ end
57
+
58
+ it 'handles the request error, authenticates, and then processes the request' do
59
+ expect(SalsaLabs::ApiResponse).to receive(:new).and_return(expired_api_response, api_response)
60
+ expect(SalsaLabs::AuthenticationResponse).to receive(:new).and_return(auth_response)
61
+ connection.request('api/getObjects.sjs', {object: 'supporter'}) do |response|
62
+ expect(response).to eq('result')
63
+ end
64
+ expect(@auth_request).to have_been_requested
65
+ expect(@api_request).to have_been_requested.twice
66
+ end
67
+
68
+ it 'breaks an infinite reauthentication loop caused by an API response that is never valid' do
69
+ expect(SalsaLabs::ApiResponse).to receive(:new).and_return(expired_api_response).twice
70
+ expect(SalsaLabs::AuthenticationResponse).to receive(:new).and_return(auth_response)
71
+ expect{ connection.request('api/getObjects.sjs', {object: 'supporter'}) }.to raise_error(SalsaLabs::AuthenticationLoopError)
72
+ expect(@auth_request).to have_been_requested
73
+ expect(@api_request).to have_been_requested.twice
74
+ end
75
+
76
+ it 'breaks an infinite reauthentication loop caused by an authentication response that is never valid' do
77
+ expect(SalsaLabs::ApiResponse).to receive(:new).and_return(expired_api_response)
78
+ expect(SalsaLabs::AuthenticationResponse).to receive(:new).and_return(failed_auth_response)
79
+ expect{ connection.request('api/getObjects.sjs', {object: 'supporter'}) }.to raise_error(SalsaLabs::AuthenticationError)
80
+ expect(@auth_request).to have_been_requested
81
+ expect(@api_request).to have_been_requested
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,62 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ describe SalsaLabs::Supporter do
5
+ context 'request methods' do
6
+ before do
7
+ expect(SalsaLabs).to receive(:request).with(path, params).and_yield(response)
8
+ end
9
+
10
+ describe '#all' do
11
+ let(:path){ 'api/getObjects.sjs' }
12
+ let(:params){ { :object => 'supporter' } }
13
+ let(:response){ fixture_file 'supporter/supporter_all.xml' }
14
+ let(:expected) do
15
+ [
16
+ {"supporter_KEY"=>"99999999", "organization_KEY"=>"99999", "chapter_KEY"=>"0", "Last_Modified"=>"Tue Aug 10 2010 15:13:10 GMT-0400 (EDT)", "Date_Created"=>"Tue Aug 10 2010 15:13:10 GMT-0400 (EDT)", "Title"=>nil, "First_Name"=>"Jane", "MI"=>nil, "Last_Name"=>"Doe", "Suffix"=>nil, "Email"=>nil, "Password"=>nil, "Receive_Email"=>"1", "Email_Status"=>nil, "Email_Preference"=>nil, "Soft_Bounce_Count"=>nil, "Hard_Bounce_Count"=>nil, "Last_Bounce"=>nil, "Receive_Phone_Blasts_BOOLVALUE"=>"false", "Receive_Phone_Blasts"=>"false", "Phone"=>"4159999999", "Cell_Phone"=>nil, "Phone_Provider"=>nil, "Work_Phone"=>nil, "Pager"=>nil, "Home_Fax"=>nil, "Work_Fax"=>nil, "Street"=>nil, "Street_2"=>nil, "Street_3"=>nil, "City"=>nil, "State"=>nil, "Zip"=>"11111", "PRIVATE_Zip_Plus_4"=>"0000", "County"=>nil, "District"=>nil, "Country"=>nil, "Latitude"=>nil, "Longitude"=>nil, "Organization"=>nil, "Department"=>nil, "Occupation"=>nil, "Instant_Messenger_Service"=>nil, "Instant_Messenger_Name"=>nil, "Web_Page"=>nil, "Alternative_Email"=>nil, "Other_Data_1"=>nil, "Other_Data_2"=>nil, "Other_Data_3"=>nil, "Notes"=>nil, "Source"=>"Web", "Source_Details"=>"http://sandbox.wiredforchange.com/o/17270/p/dia/action3/common/public/?action_KEY=425", "Source_Tracking_Code"=>"(No Original Source Available)", "Tracking_Code"=>nil, "Status"=>nil, "uid"=>nil, "Timezone"=>nil, "Language_Code"=>nil, "fbuid"=>nil, "fbtoken"=>nil, "last_action_dedication"=>nil, "split_atom_face_pic"=>nil, "key"=>"99999999", "object"=>"supporter"},
17
+ {"supporter_KEY"=>"88888888", "organization_KEY"=>"99999", "chapter_KEY"=>"0", "Last_Modified"=>"Tue Aug 10 2010 15:13:10 GMT-0400 (EDT)", "Date_Created"=>"Tue Aug 10 2010 15:13:10 GMT-0400 (EDT)", "Title"=>nil, "First_Name"=>"Jane", "MI"=>nil, "Last_Name"=>"Doe", "Suffix"=>nil, "Email"=>nil, "Password"=>nil, "Receive_Email"=>"1", "Email_Status"=>nil, "Email_Preference"=>nil, "Soft_Bounce_Count"=>nil, "Hard_Bounce_Count"=>nil, "Last_Bounce"=>nil, "Receive_Phone_Blasts_BOOLVALUE"=>"false", "Receive_Phone_Blasts"=>"false", "Phone"=>"4158888888", "Cell_Phone"=>nil, "Phone_Provider"=>nil, "Work_Phone"=>nil, "Pager"=>nil, "Home_Fax"=>nil, "Work_Fax"=>nil, "Street"=>nil, "Street_2"=>nil, "Street_3"=>nil, "City"=>nil, "State"=>nil, "Zip"=>"22222", "PRIVATE_Zip_Plus_4"=>"0000", "County"=>nil, "District"=>nil, "Country"=>nil, "Latitude"=>nil, "Longitude"=>nil, "Organization"=>nil, "Department"=>nil, "Occupation"=>nil, "Instant_Messenger_Service"=>nil, "Instant_Messenger_Name"=>nil, "Web_Page"=>nil, "Alternative_Email"=>nil, "Other_Data_1"=>nil, "Other_Data_2"=>nil, "Other_Data_3"=>nil, "Notes"=>nil, "Source"=>"Web", "Source_Details"=>"http://sandbox.wiredforchange.com/o/17270/p/dia/action3/common/public/?action_KEY=425", "Source_Tracking_Code"=>"(No Original Source Available)", "Tracking_Code"=>nil, "Status"=>nil, "uid"=>nil, "Timezone"=>nil, "Language_Code"=>nil, "fbuid"=>nil, "fbtoken"=>nil, "last_action_dedication"=>nil, "split_atom_face_pic"=>nil, "key"=>"88888888", "object"=>"supporter"}
18
+ ]
19
+ end
20
+
21
+ specify { expect(SalsaLabs::Supporter.all).to eq(expected) }
22
+ end
23
+
24
+ describe '#get' do
25
+ let(:path){ 'api/getObject.sjs' }
26
+ let(:params){ { :object => 'supporter', :key => '99999999' } }
27
+ let(:response){ fixture_file 'supporter/supporter_get.xml' }
28
+ let(:expected) do
29
+ {"supporter_KEY"=>"99999999", "organization_KEY"=>"99999", "chapter_KEY"=>"0", "Last_Modified"=>"Tue Aug 10 2010 15:13:10 GMT-0400 (EDT)", "Date_Created"=>"Tue Aug 10 2010 15:13:10 GMT-0400 (EDT)", "Title"=>nil, "First_Name"=>"Jane", "MI"=>nil, "Last_Name"=>"Doe", "Suffix"=>nil, "Email"=>nil, "Password"=>nil, "Receive_Email"=>"1", "Email_Status"=>nil, "Email_Preference"=>nil, "Soft_Bounce_Count"=>nil, "Hard_Bounce_Count"=>nil, "Last_Bounce"=>nil, "Receive_Phone_Blasts_BOOLVALUE"=>"false", "Receive_Phone_Blasts"=>"false", "Phone"=>"4159999999", "Cell_Phone"=>nil, "Phone_Provider"=>nil, "Work_Phone"=>nil, "Pager"=>nil, "Home_Fax"=>nil, "Work_Fax"=>nil, "Street"=>nil, "Street_2"=>nil, "Street_3"=>nil, "City"=>nil, "State"=>nil, "Zip"=>"11111", "PRIVATE_Zip_Plus_4"=>"0000", "County"=>nil, "District"=>nil, "Country"=>nil, "Latitude"=>nil, "Longitude"=>nil, "Organization"=>nil, "Department"=>nil, "Occupation"=>nil, "Instant_Messenger_Service"=>nil, "Instant_Messenger_Name"=>nil, "Web_Page"=>nil, "Alternative_Email"=>nil, "Other_Data_1"=>nil, "Other_Data_2"=>nil, "Other_Data_3"=>nil, "Notes"=>nil, "Source"=>"Web", "Source_Details"=>"http://sandbox.wiredforchange.com/o/17270/p/dia/action3/common/public/?action_KEY=425", "Source_Tracking_Code"=>"(No Original Source Available)", "Tracking_Code"=>nil, "Status"=>nil, "uid"=>nil, "Timezone"=>nil, "Language_Code"=>nil, "fbuid"=>nil, "fbtoken"=>nil, "last_action_dedication"=>nil, "split_atom_face_pic"=>nil, "key"=>"99999999", "object"=>"supporter"}
30
+ end
31
+
32
+ specify { expect(SalsaLabs::Supporter.get('99999999')).to eq(expected) }
33
+ end
34
+
35
+ describe '#count' do
36
+ let(:path){ 'api/getCounts.sjs' }
37
+ let(:params){ { :object => 'supporter' } }
38
+ let(:response){ fixture_file 'supporter/supporter_count.xml' }
39
+ let(:expected){ 12 }
40
+
41
+ specify { expect(SalsaLabs::Supporter.count).to eq(expected) }
42
+ end
43
+
44
+ describe '#create' do
45
+ let(:path){ 'save' }
46
+ let(:params){ { :object => 'supporter', :key => '0', :Phone => '4159876543' } }
47
+ let(:response){ fixture_file 'supporter/supporter_create.xml' }
48
+ let(:expected){ '12345678' }
49
+
50
+ specify { expect(SalsaLabs::Supporter.create(:Phone => '4159876543')).to eq(expected) }
51
+ end
52
+
53
+ describe '#update' do
54
+ let(:path){ 'save' }
55
+ let(:params){ { :object => 'supporter', :key => '12345678', :Phone => '4159876543' } }
56
+ let(:response){ fixture_file 'supporter/supporter_update.xml' }
57
+ let(:expected){ true }
58
+
59
+ specify { expect(SalsaLabs::Supporter.update('12345678', :Phone => '4159876543')).to eq(expected) }
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe SalsaLabs::SalsaObject do
4
+ before do
5
+ Klass = Class.new{ include SalsaLabs::SalsaObject }
6
+ end
7
+
8
+ it 'knows its object name' do
9
+ expect(Klass.send(:object_name)).to eq('klass')
10
+ end
11
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe SalsaLabs do
4
+ describe 'configuration' do
5
+ it 'always returns the same configuration object' do
6
+ expect(SalsaLabs.configuration).to be(SalsaLabs.configuration)
7
+ end
8
+
9
+ it 'is configurable' do
10
+ SalsaLabs.configure do |c|
11
+ c.email = 'jane@doe.com'
12
+ c.password = 'password'
13
+ end
14
+ expect(SalsaLabs.configuration.email).to eq('jane@doe.com')
15
+ expect(SalsaLabs.configuration.password).to eq('password')
16
+ end
17
+ end
18
+
19
+ describe 'request handling' do
20
+ it 'delegates requests to its connection object' do
21
+ connection = double('Connection')
22
+ response = double('response')
23
+ path = '/'
24
+ query = {}
25
+ body = 'here is the body'
26
+
27
+ expect(response).to receive(:body).and_return(body)
28
+ expect(connection).to receive(:request).with(path, query).and_yield(response)
29
+ SalsaLabs.stub(:connection){ connection }
30
+
31
+ SalsaLabs.request(path, query) do |resp|
32
+ expect(resp.body).to eq(body)
33
+ end
34
+ end
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,283 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: salsalabs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Marc Love
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 4.0.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 4.0.4
30
+ - !ruby/object:Gem::Dependency
31
+ name: nokogiri
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: faraday
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.0.rc
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.0.rc
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: yard
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: redcarpet
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: bundler
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '1.0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '2.11'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '2.11'
142
+ - !ruby/object:Gem::Dependency
143
+ name: webmock
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: 1.13.0
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: 1.13.0
158
+ - !ruby/object:Gem::Dependency
159
+ name: pry-debugger
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ description:
175
+ email:
176
+ - marcslove@gmail.com
177
+ executables: []
178
+ extensions: []
179
+ extra_rdoc_files: []
180
+ files:
181
+ - .gitignore
182
+ - .rspec
183
+ - .ruby-gemset
184
+ - .ruby-version
185
+ - .travis.yml
186
+ - Gemfile
187
+ - README.md
188
+ - Rakefile
189
+ - lib/salsa_labs.rb
190
+ - lib/salsa_labs/api_response.rb
191
+ - lib/salsa_labs/authentication_response.rb
192
+ - lib/salsa_labs/configuration.rb
193
+ - lib/salsa_labs/connection.rb
194
+ - lib/salsa_labs/objects/distributed_event.rb
195
+ - lib/salsa_labs/objects/donation.rb
196
+ - lib/salsa_labs/objects/event.rb
197
+ - lib/salsa_labs/objects/groups.rb
198
+ - lib/salsa_labs/objects/supporter.rb
199
+ - lib/salsa_labs/objects/supporter_action.rb
200
+ - lib/salsa_labs/objects/supporter_action_comment.rb
201
+ - lib/salsa_labs/objects/supporter_action_content.rb
202
+ - lib/salsa_labs/objects/supporter_action_target.rb
203
+ - lib/salsa_labs/objects/supporter_event.rb
204
+ - lib/salsa_labs/objects/supporter_groups.rb
205
+ - lib/salsa_labs/salsa_object.rb
206
+ - lib/salsa_labs/salsa_request_overwrite.rb
207
+ - lib/salsa_labs/save_response.rb
208
+ - lib/salsa_labs/version.rb
209
+ - salsalabs.gemspec
210
+ - spec/fixtures/auth_error.txt
211
+ - spec/fixtures/auth_success.txt
212
+ - spec/fixtures/expired_session.txt
213
+ - spec/fixtures/malformed_response.txt
214
+ - spec/fixtures/supporter/supporter_all.xml
215
+ - spec/fixtures/supporter/supporter_count.xml
216
+ - spec/fixtures/supporter/supporter_create.xml
217
+ - spec/fixtures/supporter/supporter_get.xml
218
+ - spec/fixtures/supporter/supporter_update.xml
219
+ - spec/fixtures/supporters.txt
220
+ - spec/integration/create_supporter_spec.rb
221
+ - spec/integration/get_supporter_spec.rb
222
+ - spec/spec_helper.rb
223
+ - spec/support/fixtures.rb
224
+ - spec/support/silence_warnings.rb
225
+ - spec/unit/salsa_labs/api_response_spec.rb
226
+ - spec/unit/salsa_labs/authentication_response_spec.rb
227
+ - spec/unit/salsa_labs/configuration_spec.rb
228
+ - spec/unit/salsa_labs/connection_spec.rb
229
+ - spec/unit/salsa_labs/objects/supporter_spec.rb
230
+ - spec/unit/salsa_labs/salsa_object_spec.rb
231
+ - spec/unit/salsa_labs_spec.rb
232
+ homepage: https://github.com/marcslove/salsa_labs
233
+ licenses:
234
+ - MIT
235
+ post_install_message:
236
+ rdoc_options: []
237
+ require_paths:
238
+ - lib
239
+ required_ruby_version: !ruby/object:Gem::Requirement
240
+ none: false
241
+ requirements:
242
+ - - ! '>='
243
+ - !ruby/object:Gem::Version
244
+ version: '0'
245
+ segments:
246
+ - 0
247
+ hash: -1486098697867355391
248
+ required_rubygems_version: !ruby/object:Gem::Requirement
249
+ none: false
250
+ requirements:
251
+ - - ! '>='
252
+ - !ruby/object:Gem::Version
253
+ version: 1.3.6
254
+ requirements: []
255
+ rubyforge_project:
256
+ rubygems_version: 1.8.29
257
+ signing_key:
258
+ specification_version: 3
259
+ summary: Salsa Labs API client library
260
+ test_files:
261
+ - spec/fixtures/auth_error.txt
262
+ - spec/fixtures/auth_success.txt
263
+ - spec/fixtures/expired_session.txt
264
+ - spec/fixtures/malformed_response.txt
265
+ - spec/fixtures/supporter/supporter_all.xml
266
+ - spec/fixtures/supporter/supporter_count.xml
267
+ - spec/fixtures/supporter/supporter_create.xml
268
+ - spec/fixtures/supporter/supporter_get.xml
269
+ - spec/fixtures/supporter/supporter_update.xml
270
+ - spec/fixtures/supporters.txt
271
+ - spec/integration/create_supporter_spec.rb
272
+ - spec/integration/get_supporter_spec.rb
273
+ - spec/spec_helper.rb
274
+ - spec/support/fixtures.rb
275
+ - spec/support/silence_warnings.rb
276
+ - spec/unit/salsa_labs/api_response_spec.rb
277
+ - spec/unit/salsa_labs/authentication_response_spec.rb
278
+ - spec/unit/salsa_labs/configuration_spec.rb
279
+ - spec/unit/salsa_labs/connection_spec.rb
280
+ - spec/unit/salsa_labs/objects/supporter_spec.rb
281
+ - spec/unit/salsa_labs/salsa_object_spec.rb
282
+ - spec/unit/salsa_labs_spec.rb
283
+ has_rdoc: