angellist_api 1.0.1 → 1.0.2

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 (94) hide show
  1. data/CHANGELOG.md +15 -0
  2. data/README.md +11 -6
  3. data/Rakefile +9 -0
  4. data/lib/angellist_api.rb +1 -3
  5. data/lib/angellist_api/api.rb +2 -4
  6. data/lib/angellist_api/authentication.rb +0 -1
  7. data/lib/angellist_api/client.rb +9 -1
  8. data/lib/angellist_api/client/activity_feeds.rb +29 -8
  9. data/lib/angellist_api/client/follows.rb +105 -63
  10. data/lib/angellist_api/client/jobs.rb +72 -0
  11. data/lib/angellist_api/client/reviews.rb +17 -6
  12. data/lib/angellist_api/client/search.rb +31 -0
  13. data/lib/angellist_api/client/startup_roles.rb +23 -8
  14. data/lib/angellist_api/client/startups.rb +49 -13
  15. data/lib/angellist_api/client/status_updates.rb +45 -24
  16. data/lib/angellist_api/client/tags.rb +52 -30
  17. data/lib/angellist_api/client/users.rb +39 -17
  18. data/lib/angellist_api/configuration.rb +24 -29
  19. data/lib/angellist_api/connection.rb +27 -29
  20. data/lib/angellist_api/core_ext/hash.rb +19 -0
  21. data/lib/angellist_api/error.rb +9 -32
  22. data/lib/angellist_api/error/bad_gateway.rb +7 -0
  23. data/lib/angellist_api/error/bad_request.rb +7 -0
  24. data/lib/angellist_api/error/enhance_your_calm.rb +13 -0
  25. data/lib/angellist_api/error/forbidden.rb +7 -0
  26. data/lib/angellist_api/error/internal_server_error.rb +7 -0
  27. data/lib/angellist_api/error/not_acceptable.rb +7 -0
  28. data/lib/angellist_api/error/not_found.rb +7 -0
  29. data/lib/angellist_api/error/service_unavailable.rb +7 -0
  30. data/lib/angellist_api/error/unauthorized.rb +7 -0
  31. data/lib/angellist_api/request.rb +11 -18
  32. data/lib/angellist_api/request/angellist_api_oauth.rb +16 -0
  33. data/lib/angellist_api/request/gateway.rb +18 -0
  34. data/lib/angellist_api/request/multipart_with_file.rb +36 -0
  35. data/lib/angellist_api/response/raise_client_error.rb +51 -0
  36. data/lib/angellist_api/response/raise_server_error.rb +27 -0
  37. data/lib/angellist_api/version.rb +1 -1
  38. data/spec/fixtures/cassettes/activity_feeds.yml +273 -0
  39. data/spec/fixtures/cassettes/follows.yml +1722 -0
  40. data/spec/fixtures/cassettes/jobs.yml +2052 -0
  41. data/spec/fixtures/cassettes/reviews.yml +93 -0
  42. data/spec/fixtures/cassettes/search.yml +169 -0
  43. data/spec/fixtures/cassettes/startup_roles.yml +1481 -0
  44. data/spec/fixtures/cassettes/startups.yml +532 -0
  45. data/spec/fixtures/cassettes/status_updates.yml +125 -0
  46. data/spec/fixtures/cassettes/tags.yml +762 -0
  47. data/spec/fixtures/cassettes/users.yml +275 -0
  48. data/spec/integration/activity_feeds_spec.rb +29 -0
  49. data/spec/integration/follows_spec.rb +60 -0
  50. data/spec/integration/jobs_spec.rb +36 -0
  51. data/spec/integration/reviews_spec.rb +15 -0
  52. data/spec/integration/search_spec.rb +27 -0
  53. data/spec/integration/startup_roles_spec.rb +25 -0
  54. data/spec/integration/startups_spec.rb +36 -0
  55. data/spec/integration/status_updates_spec.rb +18 -0
  56. data/spec/integration/tags_spec.rb +29 -0
  57. data/spec/integration/users_spec.rb +23 -0
  58. data/spec/spec_helper.rb +5 -2
  59. data/spec/support/vcr.rb +12 -0
  60. data/spec/{lib → unit/lib}/angellist_api/api_spec.rb +13 -15
  61. data/spec/unit/lib/angellist_api/authentication_spec.rb +49 -0
  62. data/spec/unit/lib/angellist_api/client/activity_feeds_spec.rb +22 -0
  63. data/spec/unit/lib/angellist_api/client/follows_spec.rb +82 -0
  64. data/spec/unit/lib/angellist_api/client/jobs_spec.rb +39 -0
  65. data/spec/unit/lib/angellist_api/client/reviews_spec.rb +14 -0
  66. data/spec/unit/lib/angellist_api/client/search_spec.rb +15 -0
  67. data/spec/unit/lib/angellist_api/client/startup_roles_spec.rb +14 -0
  68. data/spec/unit/lib/angellist_api/client/startups_spec.rb +40 -0
  69. data/spec/unit/lib/angellist_api/client/status_updates_spec.rb +30 -0
  70. data/spec/unit/lib/angellist_api/client/tags_spec.rb +39 -0
  71. data/spec/unit/lib/angellist_api/client/users_spec.rb +39 -0
  72. data/spec/{lib → unit/lib}/angellist_api/configuration_spec.rb +12 -11
  73. data/spec/unit/lib/angellist_api/error_spec.rb +124 -0
  74. data/spec/unit/lib/angellist_api/request_spec.rb +32 -0
  75. data/spec/unit/lib/angellist_api_spec.rb +42 -0
  76. metadata +128 -71
  77. data/lib/faraday/request/angellist_api_oauth.rb +0 -14
  78. data/lib/faraday/request/gateway.rb +0 -18
  79. data/lib/faraday/request/multipart_with_file.rb +0 -36
  80. data/lib/faraday/request/phoenix.rb +0 -18
  81. data/lib/faraday/response/raise_http_4xx.rb +0 -45
  82. data/lib/faraday/response/raise_http_5xx.rb +0 -24
  83. data/spec/lib/angellist_api/authentication_spec.rb +0 -53
  84. data/spec/lib/angellist_api/client/activity_feeds_spec.rb +0 -16
  85. data/spec/lib/angellist_api/client/follows_spec.rb +0 -74
  86. data/spec/lib/angellist_api/client/reviews_spec.rb +0 -16
  87. data/spec/lib/angellist_api/client/startup_roles_spec.rb +0 -16
  88. data/spec/lib/angellist_api/client/startups_spec.rb +0 -23
  89. data/spec/lib/angellist_api/client/status_updates_spec.rb +0 -32
  90. data/spec/lib/angellist_api/client/tags_spec.rb +0 -40
  91. data/spec/lib/angellist_api/client/users_spec.rb +0 -30
  92. data/spec/lib/angellist_api/error_spec.rb +0 -126
  93. data/spec/lib/angellist_api/request_spec.rb +0 -51
  94. data/spec/lib/angellist_api_spec.rb +0 -38
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe AngellistApi::Client::StartupRoles do
4
+ use_vcr_cassette 'startup_roles'
5
+
6
+ ROLES = %w[founder employee past_investor advisor incubator referrer]
7
+ let(:client) { AngellistApi::Client.new }
8
+
9
+ it "gets a startup's relationships" do
10
+ roles = client.get_startup_roles(:startup_id => 1124)
11
+ roles.startup_roles.each do |relationship|
12
+ ROLES.should include relationship.role
13
+ end
14
+ roles.startup_roles.first.should have_key :user
15
+ end
16
+
17
+ it "gets a user's relationships" do
18
+ roles = client.get_startup_roles(:user_id => 2850)
19
+ roles.startup_roles.each do |relationship|
20
+ ROLES.should include relationship.role
21
+ end
22
+ roles.startup_roles.first.should have_key :startup
23
+ end
24
+ end
25
+
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe AngellistApi::Client::Startups do
4
+ use_vcr_cassette 'startups'
5
+
6
+ let(:client) { AngellistApi::Client.new }
7
+
8
+ it 'gets information about a startup' do
9
+ startup = client.get_startup(1124)
10
+ startup.angellist_url.should eq 'http://angel.co/500-startups-fund'
11
+ end
12
+
13
+ it 'gets comments about a startup' do
14
+ comments = client.startup_comments(1124)
15
+ comments.should be_an Array
16
+ comments.first.should have_key :comment
17
+ comments.first.should have_key :user
18
+ end
19
+
20
+ it 'gets startups in batch' do
21
+ startups = client.get_startups [1124, 31627]
22
+ startups.first.name.should eq '500 Startups (Fund)'
23
+ startups.last.angellist_url.should eq 'http://angel.co/newco'
24
+ end
25
+
26
+ it 'gets information about a startup found by URL slug' do
27
+ startup = client.startup_search(:slug => '500-startups-fund')
28
+ startup.company_url.should eq 'http://500.co'
29
+ end
30
+
31
+ it 'gets information about a startup found by site domain' do
32
+ startup = client.startup_search(:domain => '500.co')
33
+ startup.angellist_url.should eq 'http://angel.co/500-startups-fund'
34
+ end
35
+ end
36
+
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe AngellistApi::Client::StatusUpdates do
4
+ use_vcr_cassette 'status_updates'
5
+
6
+ let(:client) { AngellistApi::Client.new }
7
+
8
+ it 'gets status updates for a user' do
9
+ statuses = client.get_status_updates(:user_id => 2850)
10
+ statuses.status_updates.first.should have_key :message
11
+ end
12
+
13
+ it 'gets status updates for a startup' do
14
+ statuses = client.get_status_updates(:startup_id => 1124)
15
+ statuses.status_updates.first.should have_key :message
16
+ end
17
+ end
18
+
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe AngellistApi::Client::Tags do
4
+ use_vcr_cassette 'tags'
5
+
6
+ let(:client) { AngellistApi::Client.new }
7
+
8
+ it 'gets info for a tag' do
9
+ tag = client.get_tag(856)
10
+ tag.display_name.should eq 'Venture Capital'
11
+ end
12
+
13
+ it "gets a tag's children" do
14
+ children = client.get_tag_children(856).children
15
+ children.map { |tag| tag.display_name }.should include 'Venture Hacks'
16
+ end
17
+
18
+ it "gets a tag's parents" do
19
+ parents = client.get_tag_parents(856).parents
20
+ parents.map { |tag| tag.display_name }.should include 'Organized Crime' # WTF?
21
+ end
22
+
23
+ it 'gets startups tagged with a given tag' do
24
+ tagged = client.get_tag_startups(856)
25
+ tagged.should have_key :startups
26
+ tagged.startups.first.should have_key :company_url
27
+ end
28
+ end
29
+
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe AngellistApi::Client::Users do
4
+ use_vcr_cassette 'users'
5
+
6
+ let(:client) { AngellistApi::Client.new }
7
+
8
+ it 'gets info for a user' do
9
+ user = client.get_user(2850)
10
+ user.angellist_url.should eq 'http://angel.co/500startups'
11
+ end
12
+
13
+ it 'gets users in batch' do
14
+ users = client.get_users([15821, 100303])
15
+ users.map { |u| u.angellist_url }.should eq %w[http://angel.co/tchae http://angel.co/scomma]
16
+ end
17
+
18
+ it 'gets info for a user by URL slug' do
19
+ user = client.user_search(:slug => '500startups')
20
+ user.linkedin_url.should eq 'http://www.linkedin.com/company/500-startups'
21
+ end
22
+ end
23
+
@@ -5,10 +5,13 @@ require 'rspec'
5
5
  require 'angellist_api'
6
6
  require 'timecop'
7
7
 
8
+ Dir['./spec/support/**/*.rb'].each { |f| require f }
9
+
8
10
  RSpec.configure do |config|
9
- config.mock_with :mocha
11
+ config.mock_with :rspec
10
12
 
11
13
  config.filter_run :focus => true
12
14
  config.run_all_when_everything_filtered = true
13
15
  config.color_enabled = true
14
- end
16
+ end
17
+
@@ -0,0 +1,12 @@
1
+ require 'vcr'
2
+
3
+ VCR.configure do |c|
4
+ c.cassette_library_dir = 'spec/fixtures/cassettes'
5
+ c.hook_into :faraday
6
+ c.default_cassette_options = { :record => :once }
7
+ end
8
+
9
+ RSpec.configure do |config|
10
+ config.extend VCR::RSpec::Macros
11
+ end
12
+
@@ -1,22 +1,22 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe AngellistApi::API do
4
-
4
+
5
5
  describe "#initialize" do
6
6
  context "without passing new options" do
7
- it "should use the default options" do
7
+ it "uses the default options" do
8
8
  api = AngellistApi::API.new
9
9
  AngellistApi::Configuration::VALID_OPTIONS_KEYS.each do |valid_key|
10
10
  api.send(valid_key).should == AngellistApi.options[valid_key]
11
11
  end
12
12
  end
13
13
  end
14
-
14
+
15
15
  context "while passing custom options" do
16
- it "should use the new options" do
16
+ it "uses the new options" do
17
17
  key_to_overwrite = AngellistApi.options.keys.first
18
18
  overwrite_value = "NEW VALUE!!"
19
-
19
+
20
20
  api = AngellistApi::API.new(key_to_overwrite => overwrite_value)
21
21
  AngellistApi::Configuration::VALID_OPTIONS_KEYS.each do |valid_key|
22
22
  expected_value = valid_key == key_to_overwrite ? overwrite_value : AngellistApi.options[valid_key]
@@ -25,18 +25,16 @@ describe AngellistApi::API do
25
25
  end
26
26
  end
27
27
  end
28
-
28
+
29
29
  describe "configuration" do
30
- before(:each) do
31
- @api = AngellistApi::API.new
32
- end
33
-
30
+ let(:api) { AngellistApi::API.new }
31
+
34
32
  AngellistApi::Configuration::VALID_OPTIONS_KEYS.each do |config_key|
35
- it "should allow the value of #{config_key} to be set" do
36
- lambda { @api.send("#{config_key}=", "SOME NEW VALUE") }.should_not raise_error
37
- @api.send(config_key).should == "SOME NEW VALUE"
33
+ it "allows the value of #{config_key} to be set" do
34
+ expect { api.send("#{config_key}=", "SOME NEW VALUE") }.to_not raise_error
35
+ api.send(config_key).should == "SOME NEW VALUE"
38
36
  end
39
37
  end
40
38
  end
41
-
42
- end
39
+ end
40
+
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe AngellistApi::Authentication do
4
+ class BasicClass
5
+ include AngellistApi::Authentication
6
+ end
7
+
8
+ class FullClass
9
+ include AngellistApi::Authentication
10
+ attr_accessor :access_token
11
+ end
12
+
13
+ describe "#authentication" do
14
+ context "without auth variables defined" do
15
+ it "returns a hash with nil values" do
16
+ a = BasicClass.new
17
+ a.send(:authentication).values.any?.should be_false
18
+ end
19
+ end
20
+
21
+ context "with auth variables defined" do
22
+ let(:a) { FullClass.new }
23
+
24
+ it "returns a hash with nil values if auth variables are not set" do
25
+ a.send(:authentication).values.all?.should be_false
26
+ end
27
+
28
+ it "returns a hash with nil values if auth variables are set" do
29
+ a.access_token = "token"
30
+ a.send(:authentication).values.all?.should be_true
31
+ end
32
+ end
33
+ end
34
+
35
+ describe "#authenticated?" do
36
+ let(:a) { FullClass.new }
37
+
38
+ it "returns false if authentication has any nil values" do
39
+ a.should_receive(:authentication).and_return({:access_token=>nil})
40
+ a.send(:authenticated?).should be_false
41
+ end
42
+
43
+ it "returns true if authentication has no nil values" do
44
+ a.should_receive(:authentication).and_return({:access_token=>"1"})
45
+ a.send(:authenticated?).should be_true
46
+ end
47
+ end
48
+ end
49
+
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe AngellistApi::Client::ActivityFeeds do
4
+ let(:client) { AngellistApi::Client.new }
5
+
6
+ describe "#get_feed" do
7
+ it "gets 1/feed" do
8
+ options = { :some => "options" }
9
+ client.should_receive(:get).with("1/feed", options).and_return("success")
10
+ client.get_feed(options).should == "success"
11
+ end
12
+ end
13
+
14
+ describe '#feed_item' do
15
+ it 'gets 1/feed/<id>' do
16
+ id = '8fCC3'
17
+ client.should_receive(:get).with("1/feed/#{id}").and_return('success')
18
+ client.feed_item(id).should eq 'success'
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ describe AngellistApi::Client::Follows do
4
+ let(:client) { AngellistApi::Client.new }
5
+
6
+ describe "#new_follow" do
7
+ it "posts to 1/follows" do
8
+ options = { :some => "options" }
9
+ client.should_receive(:post).with("1/follows", options).and_return("success")
10
+ client.new_follow(options).should == "success"
11
+ end
12
+ end
13
+
14
+ describe "#delete_follow" do
15
+ it "deletes 1/follows" do
16
+ options = { :some => "options" }
17
+ client.should_receive(:delete).with("1/follows", options).and_return("success")
18
+ client.delete_follow(options).should == "success"
19
+ end
20
+ end
21
+
22
+ describe '#get_follows' do
23
+ it 'gets 1/follows/batch' do
24
+ ids = [1, 2, 3]
25
+ client.should_receive(:get).
26
+ with("1/follows/batch", { :ids => ids.join(',') }).
27
+ and_return("success")
28
+ client.get_follows(ids).should == "success"
29
+ end
30
+ end
31
+
32
+ describe "#get_user_followers" do
33
+ it "gets 1/users/<id>/followers" do
34
+ id = "123"
35
+ client.should_receive(:get).with("1/users/#{id}/followers").and_return("success")
36
+ client.get_user_followers(id).should == "success"
37
+ end
38
+ end
39
+
40
+ describe "#get_user_follower_ids" do
41
+ it "gets 1/users/<id>/followers/ids" do
42
+ id = "123"
43
+ client.should_receive(:get).with("1/users/#{id}/followers/ids").and_return("success")
44
+ client.get_user_follower_ids(id).should == "success"
45
+ end
46
+ end
47
+
48
+ describe "#get_user_following" do
49
+ it "gets 1/users/<id>/following" do
50
+ id = "123"
51
+ options = { :some => "options" }
52
+ client.should_receive(:get).with("1/users/#{id}/following", options).and_return("success")
53
+ client.get_user_following(id, options).should == "success"
54
+ end
55
+ end
56
+
57
+ describe "#get_user_following_ids" do
58
+ it "gets 1/users/<id>/following/ids" do
59
+ id = "123"
60
+ options = { :some => "options" }
61
+ client.should_receive(:get).with("1/users/#{id}/following/ids", options).and_return("success")
62
+ client.get_user_following_ids(id, options).should == "success"
63
+ end
64
+ end
65
+
66
+ describe "#get_startup_followers" do
67
+ it "gets 1/startups/<id>/followers" do
68
+ id = "123"
69
+ client.should_receive(:get).with("1/startups/#{id}/followers").and_return("success")
70
+ client.get_startup_followers(id).should == "success"
71
+ end
72
+ end
73
+
74
+ describe "#get_startup_follower_ids" do
75
+ it "gets 1/startups/<id>/followers/ids" do
76
+ id = "123"
77
+ client.should_receive(:get).with("1/startups/#{id}/followers/ids").and_return("success")
78
+ client.get_startup_follower_ids(id).should == "success"
79
+ end
80
+ end
81
+ end
82
+
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe AngellistApi::Client::Jobs do
4
+ let(:client) { AngellistApi::Client.new }
5
+
6
+ describe '#get_jobs' do
7
+ it 'gets 1/jobs' do
8
+ options = { :some => "options" }
9
+ client.should_receive(:get).with('1/jobs', options).and_return('success')
10
+ client.get_jobs(options).should == 'success'
11
+ end
12
+ end
13
+
14
+ describe '#get_job' do
15
+ it 'gets 1/jobs/<id>' do
16
+ id = 123
17
+ client.should_receive(:get).with("1/jobs/#{id}").and_return('success')
18
+ client.get_job(id).should == 'success'
19
+ end
20
+ end
21
+
22
+ describe '#get_startup_jobs' do
23
+ it 'gets 1/startups/<id>/jobs' do
24
+ id = 123
25
+ client.should_receive(:get).with("1/startups/#{id}/jobs").and_return('success')
26
+ client.get_startup_jobs(id).should == 'success'
27
+ end
28
+ end
29
+
30
+ describe '#get_tag_jobs' do
31
+ it 'gets 1/tags/<id>/jobs' do
32
+ id = 123
33
+ options = { :some => 'options' }
34
+ client.should_receive(:get).with("1/tags/#{id}/jobs", options).and_return('success')
35
+ client.get_tag_jobs(id, options).should == 'success'
36
+ end
37
+ end
38
+ end
39
+
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe AngellistApi::Client::Reviews do
4
+ let(:client) { AngellistApi::Client.new }
5
+
6
+ describe "#get_reviews" do
7
+ it "gets 1/reviews" do
8
+ options = { :some => "options" }
9
+ client.should_receive(:get).with("1/reviews", options).and_return("success")
10
+ client.get_reviews(options).should == "success"
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe AngellistApi::Client::Search do
4
+ let(:client) { AngellistApi::Client.new }
5
+
6
+ describe '#search' do
7
+ it 'gets 1/search' do
8
+ query = 'pirates'
9
+ options = { :some => "options" }
10
+ client.should_receive(:get).with('1/search', options).and_return('success')
11
+ client.search(query, options).should == 'success'
12
+ end
13
+ end
14
+ end
15
+