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.
- data/CHANGELOG.md +15 -0
- data/README.md +11 -6
- data/Rakefile +9 -0
- data/lib/angellist_api.rb +1 -3
- data/lib/angellist_api/api.rb +2 -4
- data/lib/angellist_api/authentication.rb +0 -1
- data/lib/angellist_api/client.rb +9 -1
- data/lib/angellist_api/client/activity_feeds.rb +29 -8
- data/lib/angellist_api/client/follows.rb +105 -63
- data/lib/angellist_api/client/jobs.rb +72 -0
- data/lib/angellist_api/client/reviews.rb +17 -6
- data/lib/angellist_api/client/search.rb +31 -0
- data/lib/angellist_api/client/startup_roles.rb +23 -8
- data/lib/angellist_api/client/startups.rb +49 -13
- data/lib/angellist_api/client/status_updates.rb +45 -24
- data/lib/angellist_api/client/tags.rb +52 -30
- data/lib/angellist_api/client/users.rb +39 -17
- data/lib/angellist_api/configuration.rb +24 -29
- data/lib/angellist_api/connection.rb +27 -29
- data/lib/angellist_api/core_ext/hash.rb +19 -0
- data/lib/angellist_api/error.rb +9 -32
- data/lib/angellist_api/error/bad_gateway.rb +7 -0
- data/lib/angellist_api/error/bad_request.rb +7 -0
- data/lib/angellist_api/error/enhance_your_calm.rb +13 -0
- data/lib/angellist_api/error/forbidden.rb +7 -0
- data/lib/angellist_api/error/internal_server_error.rb +7 -0
- data/lib/angellist_api/error/not_acceptable.rb +7 -0
- data/lib/angellist_api/error/not_found.rb +7 -0
- data/lib/angellist_api/error/service_unavailable.rb +7 -0
- data/lib/angellist_api/error/unauthorized.rb +7 -0
- data/lib/angellist_api/request.rb +11 -18
- data/lib/angellist_api/request/angellist_api_oauth.rb +16 -0
- data/lib/angellist_api/request/gateway.rb +18 -0
- data/lib/angellist_api/request/multipart_with_file.rb +36 -0
- data/lib/angellist_api/response/raise_client_error.rb +51 -0
- data/lib/angellist_api/response/raise_server_error.rb +27 -0
- data/lib/angellist_api/version.rb +1 -1
- data/spec/fixtures/cassettes/activity_feeds.yml +273 -0
- data/spec/fixtures/cassettes/follows.yml +1722 -0
- data/spec/fixtures/cassettes/jobs.yml +2052 -0
- data/spec/fixtures/cassettes/reviews.yml +93 -0
- data/spec/fixtures/cassettes/search.yml +169 -0
- data/spec/fixtures/cassettes/startup_roles.yml +1481 -0
- data/spec/fixtures/cassettes/startups.yml +532 -0
- data/spec/fixtures/cassettes/status_updates.yml +125 -0
- data/spec/fixtures/cassettes/tags.yml +762 -0
- data/spec/fixtures/cassettes/users.yml +275 -0
- data/spec/integration/activity_feeds_spec.rb +29 -0
- data/spec/integration/follows_spec.rb +60 -0
- data/spec/integration/jobs_spec.rb +36 -0
- data/spec/integration/reviews_spec.rb +15 -0
- data/spec/integration/search_spec.rb +27 -0
- data/spec/integration/startup_roles_spec.rb +25 -0
- data/spec/integration/startups_spec.rb +36 -0
- data/spec/integration/status_updates_spec.rb +18 -0
- data/spec/integration/tags_spec.rb +29 -0
- data/spec/integration/users_spec.rb +23 -0
- data/spec/spec_helper.rb +5 -2
- data/spec/support/vcr.rb +12 -0
- data/spec/{lib → unit/lib}/angellist_api/api_spec.rb +13 -15
- data/spec/unit/lib/angellist_api/authentication_spec.rb +49 -0
- data/spec/unit/lib/angellist_api/client/activity_feeds_spec.rb +22 -0
- data/spec/unit/lib/angellist_api/client/follows_spec.rb +82 -0
- data/spec/unit/lib/angellist_api/client/jobs_spec.rb +39 -0
- data/spec/unit/lib/angellist_api/client/reviews_spec.rb +14 -0
- data/spec/unit/lib/angellist_api/client/search_spec.rb +15 -0
- data/spec/unit/lib/angellist_api/client/startup_roles_spec.rb +14 -0
- data/spec/unit/lib/angellist_api/client/startups_spec.rb +40 -0
- data/spec/unit/lib/angellist_api/client/status_updates_spec.rb +30 -0
- data/spec/unit/lib/angellist_api/client/tags_spec.rb +39 -0
- data/spec/unit/lib/angellist_api/client/users_spec.rb +39 -0
- data/spec/{lib → unit/lib}/angellist_api/configuration_spec.rb +12 -11
- data/spec/unit/lib/angellist_api/error_spec.rb +124 -0
- data/spec/unit/lib/angellist_api/request_spec.rb +32 -0
- data/spec/unit/lib/angellist_api_spec.rb +42 -0
- metadata +128 -71
- data/lib/faraday/request/angellist_api_oauth.rb +0 -14
- data/lib/faraday/request/gateway.rb +0 -18
- data/lib/faraday/request/multipart_with_file.rb +0 -36
- data/lib/faraday/request/phoenix.rb +0 -18
- data/lib/faraday/response/raise_http_4xx.rb +0 -45
- data/lib/faraday/response/raise_http_5xx.rb +0 -24
- data/spec/lib/angellist_api/authentication_spec.rb +0 -53
- data/spec/lib/angellist_api/client/activity_feeds_spec.rb +0 -16
- data/spec/lib/angellist_api/client/follows_spec.rb +0 -74
- data/spec/lib/angellist_api/client/reviews_spec.rb +0 -16
- data/spec/lib/angellist_api/client/startup_roles_spec.rb +0 -16
- data/spec/lib/angellist_api/client/startups_spec.rb +0 -23
- data/spec/lib/angellist_api/client/status_updates_spec.rb +0 -32
- data/spec/lib/angellist_api/client/tags_spec.rb +0 -40
- data/spec/lib/angellist_api/client/users_spec.rb +0 -30
- data/spec/lib/angellist_api/error_spec.rb +0 -126
- data/spec/lib/angellist_api/request_spec.rb +0 -51
- data/spec/lib/angellist_api_spec.rb +0 -38
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe AngellistApi::Error do
|
|
4
|
-
|
|
5
|
-
describe "#initialize" do
|
|
6
|
-
context "message parameter" do
|
|
7
|
-
it "should not raise an error if it is nil" do
|
|
8
|
-
lambda { AngellistApi::Error.new(nil, :header => "data") }.should_not raise_error
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "should build an error with the given message" do
|
|
12
|
-
error = AngellistApi::Error.new("bad data", :header => 'data')
|
|
13
|
-
error.message.should == "bad data"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
context "http_headers parameter" do
|
|
18
|
-
it "should raise an exception if no http headers are passed" do
|
|
19
|
-
lambda { AngellistApi::Error.new("some message", nil) }.should raise_error(ArgumentError, "odd number of arguments for Hash")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should raise an exception if the params cant be converted to a hash" do
|
|
23
|
-
lambda { AngellistApi::Error.new("some message", "header") }.should raise_error(ArgumentError, "odd number of arguments for Hash")
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should be set with the params" do
|
|
27
|
-
error = AngellistApi::Error.new("some message", :some => "value")
|
|
28
|
-
error.http_headers.should == { :some => "value" }
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe "#ratelimit_reset" do
|
|
34
|
-
it "should return the time set as x-rate-limit-reset if it's set" do
|
|
35
|
-
time1 = Time.now.to_i
|
|
36
|
-
time2 = time1 + 3600
|
|
37
|
-
error = AngellistApi::Error.new("message", {'x-ratelimit-reset' => time1, 'X-RateLimit-Reset' => time2})
|
|
38
|
-
error.ratelimit_reset.should == Time.at(time1)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should return the time set as X-RateLimit-Reset if x-rate-limit-reset is empty" do
|
|
42
|
-
time = Time.now.to_i
|
|
43
|
-
error = AngellistApi::Error.new("message", {'x-ratelimit-reset' => nil, 'X-RateLimit-Reset' => time})
|
|
44
|
-
error.ratelimit_reset.should == Time.at(time)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "should return 0 if both X-RateLimit-Reset or x-rate-limit-reset are not set" do
|
|
48
|
-
error = AngellistApi::Error.new("message", {})
|
|
49
|
-
error.ratelimit_reset.should == Time.at(0)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe "#ratelimit_limit" do
|
|
54
|
-
it "should return the number set as x-rate-limit-limit if it's set" do
|
|
55
|
-
error = AngellistApi::Error.new("message", {'x-ratelimit-limit' => 500, 'X-RateLimit-Limit' => 400})
|
|
56
|
-
error.ratelimit_limit.should == 500
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "should return the number set as X-RateLimit-Limit if x-rate-limit-limit is empty" do
|
|
60
|
-
error = AngellistApi::Error.new("message", {'x-ratelimit-limit' => nil, 'X-RateLimit-Limit' => 600})
|
|
61
|
-
error.ratelimit_limit.should == 600
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it "should return 0 if both X-RateLimit-Limit or x-rate-limit-limit are not set" do
|
|
65
|
-
error = AngellistApi::Error.new("message", {})
|
|
66
|
-
error.ratelimit_limit.should == 0
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
describe "#ratelimit_remaining" do
|
|
71
|
-
it "should return the number set as x-rate-limit-remaining if it's set" do
|
|
72
|
-
error = AngellistApi::Error.new("message", {'x-ratelimit-remaining' => 22, 'X-RateLimit-Remaining' => 23})
|
|
73
|
-
error.ratelimit_remaining.should == 22
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it "should return the number set as X-RateLimit-Remaining if x-rate-limit-remaining is empty" do
|
|
77
|
-
error = AngellistApi::Error.new("message", {'x-ratelimit-remaining' => nil, 'X-RateLimit-Remaining' => 32})
|
|
78
|
-
error.ratelimit_remaining.should == 32
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "should return 0 if both X-RateLimit-Remaining or x-rate-limit-remaining are not set" do
|
|
82
|
-
error = AngellistApi::Error.new("message", {})
|
|
83
|
-
error.ratelimit_remaining.should == 0
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
describe "#retry_after" do
|
|
88
|
-
context "a normal Error object" do
|
|
89
|
-
before(:each) do
|
|
90
|
-
@error = AngellistApi::Error.new("message", {})
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
it "should give you the time in seconds when it is acceptable to make another call" do
|
|
94
|
-
Timecop.freeze(Time.now) do
|
|
95
|
-
@error.expects(:ratelimit_reset).returns(Time.now + 3600)
|
|
96
|
-
@error.retry_after.should == 3600
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it "should return 0 if the ratelimit_reset time is in the past" do
|
|
101
|
-
Timecop.freeze(Time.now) do
|
|
102
|
-
@error.expects(:ratelimit_reset).returns(Time.now - 3600)
|
|
103
|
-
@error.retry_after.should == 0
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
context "an EnhanceYourCalm Error object" do
|
|
109
|
-
it "should return the number of seconds set as retry-after if it's set" do
|
|
110
|
-
error = AngellistApi::EnhanceYourCalm.new("message", {'retry-after' => 12, 'Retry-After' => 13})
|
|
111
|
-
error.retry_after.should == 12
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
it "should return the number set as Retry-After if retry-after is empty" do
|
|
115
|
-
error = AngellistApi::EnhanceYourCalm.new("message", {'retry-after' => nil, 'Retry-After' => 16})
|
|
116
|
-
error.retry_after.should == 16
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it "should return 0 if both Retry-After or retry-after are not set" do
|
|
120
|
-
error = AngellistApi::EnhanceYourCalm.new("message", {})
|
|
121
|
-
error.retry_after.should == 0
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe AngellistApi::Request do
|
|
4
|
-
class DummyRequest; include AngellistApi::Request; end
|
|
5
|
-
|
|
6
|
-
before(:each) do
|
|
7
|
-
@dummy = DummyRequest.new
|
|
8
|
-
@sample_path = "/index"
|
|
9
|
-
@sample_params = { :sample => "params" }
|
|
10
|
-
@sample_options = { :sample => "options" }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe "#get" do
|
|
14
|
-
it "should call request with the passed params" do
|
|
15
|
-
@dummy.expects(:request).with(:get, @sample_path, @sample_params, @sample_options).returns("result")
|
|
16
|
-
@dummy.get(@sample_path, @sample_params, @sample_options).should == "result"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe "#post" do
|
|
21
|
-
it "should call request with the passed params" do
|
|
22
|
-
@dummy.expects(:request).with(:post, @sample_path, @sample_params, @sample_options).returns("result")
|
|
23
|
-
@dummy.post(@sample_path, @sample_params, @sample_options).should == "result"
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
describe "#put" do
|
|
28
|
-
it "should call request with the passed params" do
|
|
29
|
-
@dummy.expects(:request).with(:put, @sample_path, @sample_params, @sample_options).returns("result")
|
|
30
|
-
@dummy.put(@sample_path, @sample_params, @sample_options).should == "result"
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
describe "#delete" do
|
|
35
|
-
it "should call request with the passed params" do
|
|
36
|
-
@dummy.expects(:request).with(:delete, @sample_path, @sample_params, @sample_options).returns("result")
|
|
37
|
-
@dummy.delete(@sample_path, @sample_params, @sample_options).should == "result"
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
describe "#formatted_path" do
|
|
42
|
-
it "should return a string with the path without the given format appended" do
|
|
43
|
-
@dummy.send(:formatted_path, @sample_path, {:format => 'json'}).should == "/index"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "should not throw an error options[:format] is not provided" do
|
|
47
|
-
lambda { @dummy.send(:formatted_path, @sample_path) }.should_not raise_error
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe AngellistApi do
|
|
4
|
-
|
|
5
|
-
describe ".new" do
|
|
6
|
-
it "should be an alias for AngellistApi::Client.new" do
|
|
7
|
-
options = { :some => "option" }
|
|
8
|
-
AngellistApi.new(options).class.name.should == "AngellistApi::Client"
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe ".method_missing" do
|
|
13
|
-
context "with a method known to AngellistApi::Client" do
|
|
14
|
-
it "should pass the method call to AngellistApi::Client" do
|
|
15
|
-
expected_result = {:some => "result"}
|
|
16
|
-
AngellistApi::Client.any_instance.expects(:startup_search).returns(expected_result)
|
|
17
|
-
lambda { AngellistApi.startup_search(:slug => 'angellist').should == expected_result }.should_not raise_error
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
context "with a method unknown to AngellistApi::Client" do
|
|
22
|
-
it "should raise method not found error" do
|
|
23
|
-
lambda { AngellistApi.some_unknown_method }.should raise_error(NoMethodError)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe ".respond_to?" do
|
|
29
|
-
it "should return true if AngellistApi::Client responds to the method" do
|
|
30
|
-
AngellistApi.respond_to?(:startup_search).should be_true
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "should return false if AngellistApi::Client does not respond to the method" do
|
|
34
|
-
AngellistApi.respond_to?(:some_unknown_method).should be_false
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|