linkedin-saimonmoore 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <current-status>New blog post: What makes a good API wrapper? http://wynnnetherland.com/2009/11/what-makes-a-good-api-wrapper/</current-status>
@@ -0,0 +1,117 @@
1
+ require 'test_helper'
2
+
3
+ class OAuthTest < Test::Unit::TestCase
4
+ should "initialize with consumer token and secret" do
5
+ linkedin = LinkedIn::Client.new('token', 'secret')
6
+
7
+ linkedin.ctoken.should == 'token'
8
+ linkedin.csecret.should == 'secret'
9
+ end
10
+
11
+ should "set authorization path to '/uas/oauth/authorize' by default" do
12
+ linkedin = LinkedIn::Client.new('token', 'secret')
13
+ linkedin.consumer.options[:authorize_path].should == '/uas/oauth/authorize'
14
+ end
15
+
16
+ should "have a consumer" do
17
+ consumer = mock('oauth consumer')
18
+ options = {
19
+ :request_token_path => "/uas/oauth/requestToken",
20
+ :access_token_path => "/uas/oauth/accessToken",
21
+ :authorize_path => "/uas/oauth/authorize",
22
+ :site => 'https://api.linkedin.com'
23
+ }
24
+ OAuth::Consumer.expects(:new).with('token', 'secret', options).returns(consumer)
25
+ linkedin = LinkedIn::Client.new('token', 'secret')
26
+
27
+ linkedin.consumer.should == consumer
28
+ end
29
+
30
+ should "have a request token from the consumer" do
31
+ options = {
32
+ :request_token_path => "/uas/oauth/requestToken",
33
+ :access_token_path => "/uas/oauth/accessToken",
34
+ :authorize_path => "/uas/oauth/authorize",
35
+ :site => 'https://api.linkedin.com'
36
+ }
37
+ consumer = mock('oauth consumer')
38
+ request_token = mock('request token')
39
+ consumer.expects(:get_request_token).returns(request_token)
40
+ OAuth::Consumer.expects(:new).with('token', 'secret', options).returns(consumer)
41
+ linkedin = LinkedIn::Client.new('token', 'secret')
42
+
43
+ linkedin.request_token.should == request_token
44
+ end
45
+
46
+ context "set_callback_url" do
47
+ should "clear request token and set the callback url" do
48
+ consumer = mock('oauth consumer')
49
+ request_token = mock('request token')
50
+ options = {
51
+ :request_token_path => "/uas/oauth/requestToken",
52
+ :access_token_path => "/uas/oauth/accessToken",
53
+ :authorize_path => "/uas/oauth/authorize",
54
+ :site => 'https://api.linkedin.com'
55
+ }
56
+ OAuth::Consumer.
57
+ expects(:new).
58
+ with('token', 'secret', options).
59
+ returns(consumer)
60
+
61
+ linkedin = LinkedIn::Client.new('token', 'secret')
62
+
63
+ consumer.
64
+ expects(:get_request_token).
65
+ with({:oauth_callback => 'http://myapp.com/oauth_callback'})
66
+
67
+ linkedin.set_callback_url('http://myapp.com/oauth_callback')
68
+ end
69
+ end
70
+
71
+ should "be able to create access token from request token, request secret and verifier" do
72
+ linkedin = LinkedIn::Client.new('token', 'secret')
73
+ consumer = OAuth::Consumer.new('token', 'secret', {:site => 'https://api.linkedin.com'})
74
+ linkedin.stubs(:consumer).returns(consumer)
75
+
76
+ access_token = mock('access token', :token => 'atoken', :secret => 'asecret')
77
+ request_token = mock('request token')
78
+ request_token.
79
+ expects(:get_access_token).
80
+ with(:oauth_verifier => 'verifier').
81
+ returns(access_token)
82
+
83
+ OAuth::RequestToken.
84
+ expects(:new).
85
+ with(consumer, 'rtoken', 'rsecret').
86
+ returns(request_token)
87
+
88
+ linkedin.authorize_from_request('rtoken', 'rsecret', 'verifier')
89
+ linkedin.access_token.class.should be(OAuth::AccessToken)
90
+ linkedin.access_token.token.should == 'atoken'
91
+ linkedin.access_token.secret.should == 'asecret'
92
+ end
93
+
94
+ should "be able to create access token from access token and secret" do
95
+ linkedin = LinkedIn::Client.new('token', 'secret')
96
+ consumer = OAuth::Consumer.new('token', 'secret', {:site => 'https://api.linkedin.com'})
97
+ linkedin.stubs(:consumer).returns(consumer)
98
+
99
+ linkedin.authorize_from_access('atoken', 'asecret')
100
+ linkedin.access_token.class.should be(OAuth::AccessToken)
101
+ linkedin.access_token.token.should == 'atoken'
102
+ linkedin.access_token.secret.should == 'asecret'
103
+ end
104
+
105
+ should "be able to configure consumer token and consumer secret without passing to initialize" do
106
+ LinkedIn.configure do |config|
107
+ config.token = 'consumer_token'
108
+ config.secret = 'consumer_secret'
109
+ end
110
+
111
+ linkedin = LinkedIn::Client.new
112
+ linkedin.ctoken.should == 'consumer_token'
113
+ linkedin.csecret.should == 'consumer_secret'
114
+ end
115
+
116
+
117
+ end
@@ -0,0 +1,51 @@
1
+ require 'test/unit'
2
+ require 'pathname'
3
+ require 'rubygems'
4
+
5
+ gem 'thoughtbot-shoulda', '>= 2.10.1'
6
+ gem 'jnunemaker-matchy', '0.4.0'
7
+ gem 'mocha', '0.9.4'
8
+ gem 'fakeweb', '>= 1.2.5'
9
+
10
+ require 'shoulda'
11
+ require 'matchy'
12
+ require 'mocha'
13
+ require 'fakeweb'
14
+
15
+ FakeWeb.allow_net_connect = false
16
+
17
+ dir = (Pathname(__FILE__).dirname + '../lib').expand_path
18
+ require dir + 'linkedin'
19
+
20
+ class Test::Unit::TestCase
21
+ end
22
+
23
+ def fixture_file(filename)
24
+ return '' if filename == ''
25
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
26
+ File.read(file_path)
27
+ end
28
+
29
+ def linkedin_url(url)
30
+ url =~ /^http/ ? url : "https://api.linkedin.com#{url}"
31
+ end
32
+
33
+ def stub_get(url, filename, status=nil)
34
+ options = {:body => fixture_file(filename)}
35
+ options.merge!({:status => status}) unless status.nil?
36
+
37
+ FakeWeb.register_uri(:get, linkedin_url(url), options)
38
+ end
39
+
40
+ def stub_post(url, filename)
41
+ FakeWeb.register_uri(:post, linkedin_url(url), :body => fixture_file(filename))
42
+ end
43
+
44
+ def stub_put(url, filename)
45
+ FakeWeb.register_uri(:put, linkedin_url(url), :body => fixture_file(filename))
46
+ end
47
+
48
+ def stub_delete(url, filename)
49
+ FakeWeb.register_uri(:delete, linkedin_url(url), :body => fixture_file(filename))
50
+
51
+ end
metadata ADDED
@@ -0,0 +1,200 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: linkedin-saimonmoore
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 8
9
+ version: 0.1.8
10
+ platform: ruby
11
+ authors:
12
+ - Wynn Netherland
13
+ - Saimon Moore
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-02-05 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: oauth
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 3
31
+ - 5
32
+ version: 0.3.5
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: roxml
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 3
44
+ - 1
45
+ - 3
46
+ version: 3.1.3
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: crack
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ - 1
59
+ - 4
60
+ version: 0.1.4
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: thoughtbot-shoulda
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 2
72
+ - 10
73
+ - 1
74
+ version: 2.10.1
75
+ type: :development
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: jnunemaker-matchy
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
86
+ - 4
87
+ - 0
88
+ version: 0.4.0
89
+ type: :development
90
+ version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
92
+ name: mocha
93
+ prerelease: false
94
+ requirement: &id006 !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "="
97
+ - !ruby/object:Gem::Version
98
+ segments:
99
+ - 0
100
+ - 9
101
+ - 4
102
+ version: 0.9.4
103
+ type: :development
104
+ version_requirements: *id006
105
+ - !ruby/object:Gem::Dependency
106
+ name: fakeweb
107
+ prerelease: false
108
+ requirement: &id007 !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ segments:
113
+ - 1
114
+ - 2
115
+ - 5
116
+ version: 1.2.5
117
+ type: :development
118
+ version_requirements: *id007
119
+ description: Ruby wrapper for the LinkedIn API
120
+ email: wynn.netherland@gmail.com
121
+ executables: []
122
+
123
+ extensions: []
124
+
125
+ extra_rdoc_files:
126
+ - LICENSE
127
+ - README.markdown
128
+ files:
129
+ - LICENSE
130
+ - README.markdown
131
+ - Rakefile
132
+ - VERSION
133
+ - lib/linked_in/api_standard_profile_request.rb
134
+ - lib/linked_in/client.rb
135
+ - lib/linked_in/company.rb
136
+ - lib/linked_in/connections.rb
137
+ - lib/linked_in/country.rb
138
+ - lib/linked_in/education.rb
139
+ - lib/linked_in/error.rb
140
+ - lib/linked_in/group.rb
141
+ - lib/linked_in/location.rb
142
+ - lib/linked_in/network.rb
143
+ - lib/linked_in/people.rb
144
+ - lib/linked_in/position.rb
145
+ - lib/linked_in/profile.rb
146
+ - lib/linked_in/update.rb
147
+ - lib/linked_in/url_resource.rb
148
+ - lib/linkedin.rb
149
+ - test/client_test.rb
150
+ - test/fixtures/blank.xml
151
+ - test/fixtures/connections.xml
152
+ - test/fixtures/error.xml
153
+ - test/fixtures/network_status_with_group.xml
154
+ - test/fixtures/network_statuses.xml
155
+ - test/fixtures/picture_updates.xml
156
+ - test/fixtures/profile.xml
157
+ - test/fixtures/profile_full.xml
158
+ - test/fixtures/profile_with_positions.xml
159
+ - test/fixtures/search.xml
160
+ - test/fixtures/status.xml
161
+ - test/oauth_test.rb
162
+ - test/test_helper.rb
163
+ has_rdoc: true
164
+ homepage: http://github.com/pengwynn/linkedin
165
+ licenses: []
166
+
167
+ post_install_message:
168
+ rdoc_options:
169
+ - --charset=UTF-8
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ segments:
177
+ - 0
178
+ version: "0"
179
+ required_rubygems_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ segments:
184
+ - 0
185
+ version: "0"
186
+ requirements: []
187
+
188
+ rubyforge_project:
189
+ rubygems_version: 1.3.6
190
+ signing_key:
191
+ specification_version: 3
192
+ summary: Ruby wrapper for the LinkedIn API
193
+ test_files:
194
+ - test/client_test.rb
195
+ - test/oauth_test.rb
196
+ - test/test_helper.rb
197
+ - examples/authenticate.rb
198
+ - examples/network.rb
199
+ - examples/profile.rb
200
+ - examples/status.rb