kippt 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.md +6 -0
- data/kippt.gemspec +1 -1
- data/lib/kippt/collection.rb +4 -4
- data/lib/kippt/read_collection_resource.rb +0 -6
- data/lib/kippt/version.rb +1 -1
- data/spec/kippt/client_spec.rb +16 -16
- data/spec/kippt/clip_collection_spec.rb +2 -1
- data/spec/kippt/clip_spec.rb +31 -31
- data/spec/kippt/clips_spec.rb +13 -13
- data/spec/kippt/comment_spec.rb +2 -2
- data/spec/kippt/comments_spec.rb +18 -38
- data/spec/kippt/favorite_spec.rb +10 -10
- data/spec/kippt/favorites_spec.rb +3 -3
- data/spec/kippt/follow_relationship_spec.rb +7 -7
- data/spec/kippt/like_spec.rb +10 -10
- data/spec/kippt/likes_spec.rb +3 -3
- data/spec/kippt/list_collection_spec.rb +2 -1
- data/spec/kippt/list_spec.rb +20 -20
- data/spec/kippt/lists_spec.rb +2 -2
- data/spec/kippt/saves_spec.rb +2 -2
- data/spec/kippt/user_clips_spec.rb +4 -4
- data/spec/kippt/user_collection_spec.rb +2 -1
- data/spec/kippt/user_lists_spec.rb +2 -2
- data/spec/kippt/user_spec.rb +14 -14
- data/spec/kippt/users_spec.rb +4 -4
- data/spec/shared_examples/collection.rb +26 -26
- data/spec/shared_examples/collection_resource.rb +2 -2
- data/spec/shared_examples/read_collection_resource.rb +8 -28
- data/spec/shared_examples/resource.rb +20 -20
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Y2JmNmVjOTc5MTNmNTg2Y2U4NGEzNGFmY2Y5MjQxNWU0MjAzNDc2YQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 80e2fac4be245de12f3fee8ded602b664f8835c6
|
4
|
+
data.tar.gz: 45c5189f649696dfc64549e52f0814e613808923
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
OGY4ZTYxOTYwYjE4OTk5MDRkYTA0M2E5ZjhmYTdjZWZjN2EzODdlZTgwYzY5
|
11
|
-
NzdhYWM2ZDJlMDI2YjQzYzJhOGI3NDc2MWE5M2Y5ZDQ0Yjg0OWI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MGYzMTJjZTVkNDk3NjE5ZTlkZTQxMmJkOTU3M2I2NzlmNTM0MTJkOTIzZmNj
|
14
|
-
ZGY1MmViMTQ2MGE3ZGIxM2VmOGZlMjI5MzA4ZGY0OWZkNjdiYWYwYjhjYzIw
|
15
|
-
Mjg1N2YzZTU3NzZlZGM3MmMwMmQ5NDk0YTY5Y2ExOGIzNmI4YTM=
|
6
|
+
metadata.gz: 4ad46f521ca0a8d113d48cbd58126e236035f0487001e1c8635ad24f253fac6a77156af82c3b9dd8ac0deadc15d7066be76cb9f36e4e78de489bb60d74776f1c
|
7
|
+
data.tar.gz: aca191768fb9801d485f101ea781ceb84c85cff81cc5ec45a2510c3d32884cce984ac4afadcfd9c25139c31bc5d351609f737383fa3d7a465746568a8a706dab
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.1 / July 31, 2015
|
4
|
+
|
5
|
+
Fixes bug with fetching next & previous page of clips.
|
6
|
+
|
7
|
+
Updates RSpec to >= 3.0 and updates the test syntax to use the `expect`-style.
|
8
|
+
|
3
9
|
## 3.0 / December 23, 2013
|
4
10
|
|
5
11
|
Changes all fetching to paginated HTTP endpoints to return a proxy so that you can control
|
data/kippt.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_dependency "faraday_middleware", "~> 0.8"
|
20
20
|
gem.add_dependency "multi_json", "~> 1.3"
|
21
21
|
|
22
|
-
gem.add_development_dependency "rspec", "~>
|
22
|
+
gem.add_development_dependency "rspec", "~> 3.0"
|
23
23
|
gem.add_development_dependency "webmock", "~> 1.11"
|
24
24
|
gem.add_development_dependency "simplecov", "~> 0.7"
|
25
25
|
end
|
data/lib/kippt/collection.rb
CHANGED
@@ -37,7 +37,7 @@ module Kippt::Collection
|
|
37
37
|
def next_page
|
38
38
|
raise Kippt::APIError.new("There is no next page") if @next.nil? || @next == ""
|
39
39
|
|
40
|
-
|
40
|
+
collection_resource_from_url(@next).fetch
|
41
41
|
end
|
42
42
|
|
43
43
|
def previous_page?
|
@@ -48,14 +48,14 @@ module Kippt::Collection
|
|
48
48
|
def previous_page
|
49
49
|
raise Kippt::APIError.new("There is no previous page") if @previous.nil? || @previous == ""
|
50
50
|
|
51
|
-
|
51
|
+
collection_resource_from_url(@previous).fetch
|
52
52
|
end
|
53
53
|
alias_method :prev_page, :previous_page
|
54
54
|
|
55
55
|
private
|
56
56
|
|
57
|
-
def
|
58
|
-
|
57
|
+
def collection_resource_from_url(url)
|
58
|
+
client.collection_resource_for(collection_resource_class, url)
|
59
59
|
end
|
60
60
|
|
61
61
|
def client
|
@@ -24,12 +24,6 @@ module Kippt::ReadCollectionResource
|
|
24
24
|
|
25
25
|
alias find []
|
26
26
|
|
27
|
-
def collection_from_url(url)
|
28
|
-
raise ArgumentError.new("The parameter URL can't be blank") if url.nil? || url == ""
|
29
|
-
|
30
|
-
collection_class.new(client.get(url).body, client)
|
31
|
-
end
|
32
|
-
|
33
27
|
private
|
34
28
|
|
35
29
|
def validate_collection_options(options)
|
data/lib/kippt/version.rb
CHANGED
data/spec/kippt/client_spec.rb
CHANGED
@@ -30,7 +30,7 @@ describe Kippt::Client do
|
|
30
30
|
context "when debug is set to true" do
|
31
31
|
it "sets client to debug mode" do
|
32
32
|
client = Kippt::Client.new(:unauthenticated => true, :debug => true)
|
33
|
-
client.debug
|
33
|
+
expect(client.debug?).to be_truthy
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -38,9 +38,9 @@ describe Kippt::Client do
|
|
38
38
|
context "#debug" do
|
39
39
|
it "can be set and read" do
|
40
40
|
client = Kippt::Client.new(:unauthenticated => true)
|
41
|
-
client.debug
|
41
|
+
expect(client.debug?).to be_falsey
|
42
42
|
client.debug = true
|
43
|
-
client.debug
|
43
|
+
expect(client.debug?).to be_truthy
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -84,17 +84,17 @@ describe Kippt::Client do
|
|
84
84
|
subject { Kippt::Client.new(:username => "bob", :password => "secret") }
|
85
85
|
|
86
86
|
it "returns a Kippt::User instance" do
|
87
|
-
subject.
|
88
|
-
|
87
|
+
expect(subject).to receive(:get).with("account").and_return(
|
88
|
+
double :body => {}
|
89
89
|
)
|
90
90
|
account = subject.account
|
91
|
-
account.
|
91
|
+
expect(account).to be_a(Kippt::User)
|
92
92
|
end
|
93
93
|
|
94
94
|
context "when asked for api token" do
|
95
95
|
it "asks for the token from the server" do
|
96
|
-
subject.
|
97
|
-
|
96
|
+
expect(subject).to receive(:get).with("account?include_data=api_token").and_return(
|
97
|
+
double :body => {}
|
98
98
|
)
|
99
99
|
account = subject.account(true)
|
100
100
|
end
|
@@ -106,7 +106,7 @@ describe Kippt::Client do
|
|
106
106
|
|
107
107
|
it "returns a Kippt::Lists instance" do
|
108
108
|
lists = subject.lists
|
109
|
-
lists.
|
109
|
+
expect(lists).to be_a(Kippt::Lists)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -115,7 +115,7 @@ describe Kippt::Client do
|
|
115
115
|
|
116
116
|
it "returns a Kippt::RootClips instance" do
|
117
117
|
clips = subject.clips
|
118
|
-
clips.
|
118
|
+
expect(clips).to be_a(Kippt::RootClips)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -124,7 +124,7 @@ describe Kippt::Client do
|
|
124
124
|
|
125
125
|
it "returns a Kippt::Users instance" do
|
126
126
|
users = subject.users
|
127
|
-
users.
|
127
|
+
expect(users).to be_a(Kippt::Users)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
@@ -132,12 +132,12 @@ describe Kippt::Client do
|
|
132
132
|
subject { Kippt::Client.new(valid_user_credentials) }
|
133
133
|
|
134
134
|
it "returns instance of the resource class" do
|
135
|
-
subject.collection_resource_for(Kippt::Users).
|
135
|
+
expect(subject.collection_resource_for(Kippt::Users)).to be_a(Kippt::Users)
|
136
136
|
end
|
137
137
|
|
138
138
|
it "passes itself and the passed arguments as parameters" do
|
139
139
|
resource_class = double :resource
|
140
|
-
resource_class.
|
140
|
+
expect(resource_class).to receive(:new).with(subject, :option1, :option2)
|
141
141
|
subject.collection_resource_for(resource_class, :option1, :option2)
|
142
142
|
end
|
143
143
|
end
|
@@ -149,16 +149,16 @@ describe Kippt::Client do
|
|
149
149
|
stub_get("/users/10").
|
150
150
|
to_return(:status => 200, :body => fixture("user.json"))
|
151
151
|
resource = subject.resource_from_url(Kippt::User, "/api/users/10")
|
152
|
-
resource.
|
152
|
+
expect(resource).to be_a(Kippt::User)
|
153
153
|
end
|
154
154
|
|
155
155
|
context "when passed URL is blank" do
|
156
156
|
it "raises ArgumentError" do
|
157
157
|
expect {
|
158
|
-
subject.resource_from_url(
|
158
|
+
subject.resource_from_url(double, "")
|
159
159
|
}.to raise_error(ArgumentError, "The parameter URL can't be blank")
|
160
160
|
expect {
|
161
|
-
subject.resource_from_url(
|
161
|
+
subject.resource_from_url(double, nil)
|
162
162
|
}.to raise_error(ArgumentError, "The parameter URL can't be blank")
|
163
163
|
end
|
164
164
|
end
|
@@ -6,9 +6,10 @@ describe Kippt::ClipCollection do
|
|
6
6
|
let(:data_with_multiple_pages) {
|
7
7
|
MultiJson.load(fixture("clips_with_multiple_pages.json").read)
|
8
8
|
}
|
9
|
-
let(:client) {
|
9
|
+
let(:client) { double(:client) }
|
10
10
|
subject { Kippt::ClipCollection.new(data, client) }
|
11
11
|
let(:subject_with_multiple_pages) { Kippt::ClipCollection.new(data_with_multiple_pages, client) }
|
12
|
+
let(:collection_resource_class) { Kippt::Clips }
|
12
13
|
|
13
14
|
it_behaves_like "collection"
|
14
15
|
end
|
data/spec/kippt/clip_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe Kippt::Clip do
|
|
23
23
|
let(:data) { {"list" => "/api/lists/44525/"} }
|
24
24
|
|
25
25
|
it "returns the URI" do
|
26
|
-
subject.list_uri.
|
26
|
+
expect(subject.list_uri).to eq "/api/lists/44525/"
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -31,7 +31,7 @@ describe Kippt::Clip do
|
|
31
31
|
let(:data) { {"list" => {"resource_uri" => "/api/lists/44525/"}} }
|
32
32
|
|
33
33
|
it "returns the uri of the embedded list" do
|
34
|
-
subject.list_uri.
|
34
|
+
expect(subject.list_uri).to eq "/api/lists/44525/"
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -44,7 +44,7 @@ describe Kippt::Clip do
|
|
44
44
|
stub_get("/lists/44525/").
|
45
45
|
to_return(:status => 200, :body => fixture("list.json"))
|
46
46
|
|
47
|
-
subject.list.
|
47
|
+
expect(subject.list).to be_a Kippt::List
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -52,7 +52,7 @@ describe Kippt::Clip do
|
|
52
52
|
let(:data) { {"list" => {"resource_uri" => "/api/lists/44525/"}} }
|
53
53
|
|
54
54
|
it "returns an instance using the embedded list" do
|
55
|
-
subject.list.
|
55
|
+
expect(subject.list).to be_a Kippt::List
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -61,18 +61,18 @@ describe Kippt::Clip do
|
|
61
61
|
let(:data) { {"list" => list} }
|
62
62
|
|
63
63
|
it "returns the passed list" do
|
64
|
-
subject.list.
|
64
|
+
expect(subject.list).to eq list
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
describe "#comments" do
|
70
70
|
it "returns Kippt::Comments" do
|
71
|
-
subject.comments.
|
71
|
+
expect(subject.comments).to be_a Kippt::Comments
|
72
72
|
end
|
73
73
|
|
74
74
|
it "returns object where clip is set" do
|
75
|
-
subject.comments.clip.
|
75
|
+
expect(subject.comments.clip).to eq subject
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -83,7 +83,7 @@ describe Kippt::Clip do
|
|
83
83
|
}} }
|
84
84
|
|
85
85
|
it "returns true" do
|
86
|
-
subject.all_comments_embedded
|
86
|
+
expect(subject.all_comments_embedded?).to be_truthy
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -93,18 +93,18 @@ describe Kippt::Clip do
|
|
93
93
|
}} }
|
94
94
|
|
95
95
|
it "returns false" do
|
96
|
-
subject.all_comments_embedded
|
96
|
+
expect(subject.all_comments_embedded?).to be_falsey
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
101
|
describe "#likes" do
|
102
102
|
it "returns Kippt::ClipLikes" do
|
103
|
-
subject.likes.
|
103
|
+
expect(subject.likes).to be_a Kippt::ClipLikes
|
104
104
|
end
|
105
105
|
|
106
106
|
it "returns object where clip is set" do
|
107
|
-
subject.likes.clip.
|
107
|
+
expect(subject.likes.clip).to eq subject
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -115,7 +115,7 @@ describe Kippt::Clip do
|
|
115
115
|
}} }
|
116
116
|
|
117
117
|
it "returns true" do
|
118
|
-
subject.all_likes_embedded
|
118
|
+
expect(subject.all_likes_embedded?).to be_truthy
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -125,81 +125,81 @@ describe Kippt::Clip do
|
|
125
125
|
}} }
|
126
126
|
|
127
127
|
it "returns false" do
|
128
|
-
subject.all_likes_embedded
|
128
|
+
expect(subject.all_likes_embedded?).to be_falsey
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
133
|
describe "#likes_count" do
|
134
134
|
it "returns the likes count from the response" do
|
135
|
-
subject.likes_count.
|
135
|
+
expect(subject.likes_count).to eq 0
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
139
|
describe "#likes_data" do
|
140
140
|
it "returns the likes data from the response" do
|
141
|
-
subject.likes_data.
|
141
|
+
expect(subject.likes_data).to eq []
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
145
|
describe "#saves" do
|
146
146
|
it "returns Kippt::Saves" do
|
147
|
-
subject.saves.
|
147
|
+
expect(subject.saves).to be_a Kippt::Saves
|
148
148
|
end
|
149
149
|
|
150
150
|
it "returns object where clip is set" do
|
151
|
-
subject.saves.clip.
|
151
|
+
expect(subject.saves.clip).to eq subject
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
155
|
describe "#saves_count" do
|
156
156
|
it "returns the saves count from the response" do
|
157
|
-
subject.saves_count.
|
157
|
+
expect(subject.saves_count).to eq 0
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
161
|
describe "#saves_data" do
|
162
162
|
it "returns the saves data from the response" do
|
163
|
-
subject.saves_data.
|
163
|
+
expect(subject.saves_data).to eq []
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
167
|
describe "#like" do
|
168
|
-
let(:like) {
|
168
|
+
let(:like) { double :like }
|
169
169
|
|
170
170
|
it "instantiates a Kippt::Like and saves it" do
|
171
|
-
Kippt::Like.
|
172
|
-
like.
|
171
|
+
expect(Kippt::Like).to receive(:new).with(subject, client).and_return(like)
|
172
|
+
expect(like).to receive(:save)
|
173
173
|
subject.like
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
177
|
describe "#unlike" do
|
178
|
-
let(:like) {
|
178
|
+
let(:like) { double :like }
|
179
179
|
|
180
180
|
it "instantiates a Kippt::Like and destroys it" do
|
181
|
-
Kippt::Like.
|
182
|
-
like.
|
181
|
+
expect(Kippt::Like).to receive(:new).with(subject, client).and_return(like)
|
182
|
+
expect(like).to receive(:destroy)
|
183
183
|
subject.unlike
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
187
|
describe "#favorite" do
|
188
|
-
let(:favorite) {
|
188
|
+
let(:favorite) { double :favorite }
|
189
189
|
|
190
190
|
it "instantiates a Kippt::Favorite and saves it" do
|
191
|
-
Kippt::Favorite.
|
192
|
-
favorite.
|
191
|
+
expect(Kippt::Favorite).to receive(:new).with(subject, client).and_return(favorite)
|
192
|
+
expect(favorite).to receive(:save)
|
193
193
|
subject.favorite
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
197
|
describe "#unlike" do
|
198
|
-
let(:favorite) {
|
198
|
+
let(:favorite) { double :favorite }
|
199
199
|
|
200
200
|
it "instantiates a Kippt::Favorite and destroys it" do
|
201
|
-
Kippt::Favorite.
|
202
|
-
favorite.
|
201
|
+
expect(Kippt::Favorite).to receive(:new).with(subject, client).and_return(favorite)
|
202
|
+
expect(favorite).to receive(:destroy)
|
203
203
|
subject.unfavorite
|
204
204
|
end
|
205
205
|
end
|
data/spec/kippt/clips_spec.rb
CHANGED
@@ -14,11 +14,11 @@ describe Kippt::Clips do
|
|
14
14
|
|
15
15
|
describe "#build" do
|
16
16
|
it "returns new resource" do
|
17
|
-
subject.build.
|
17
|
+
expect(subject.build).to be_a(resource_class)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "accepts parameters" do
|
21
|
-
subject.object_class.
|
21
|
+
expect(subject.object_class).to receive(:new).with({:an => "attribute"}, client)
|
22
22
|
subject.build(:an => "attribute")
|
23
23
|
end
|
24
24
|
end
|
@@ -28,8 +28,8 @@ describe Kippt::Clips do
|
|
28
28
|
|
29
29
|
it "returns Clips" do
|
30
30
|
feed = subject.feed
|
31
|
-
feed.
|
32
|
-
feed.base_uri.
|
31
|
+
expect(feed).to be_a Kippt::Clips
|
32
|
+
expect(feed.base_uri).to eq "clips/feed"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -38,8 +38,8 @@ describe Kippt::Clips do
|
|
38
38
|
|
39
39
|
it "returns Clips" do
|
40
40
|
feed = subject.favorites
|
41
|
-
feed.
|
42
|
-
feed.base_uri.
|
41
|
+
expect(feed).to be_a Kippt::Clips
|
42
|
+
expect(feed.base_uri).to eq "clips/favorites"
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -66,9 +66,9 @@ describe Kippt::Clips do
|
|
66
66
|
|
67
67
|
context "with invalid keys" do
|
68
68
|
it "raises ArgumentError" do
|
69
|
-
|
69
|
+
expect {
|
70
70
|
subject.search(:q => "bunny", :stuff => true)
|
71
|
-
}.
|
71
|
+
}.to raise_error(ArgumentError, "'stuff' is not a valid search parameter")
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -78,7 +78,7 @@ describe Kippt::Clips do
|
|
78
78
|
stub_get("/search/clips?q=bunny").
|
79
79
|
to_return(:status => 200, :body => fixture("clips.json"))
|
80
80
|
clips = subject.search("bunny")
|
81
|
-
clips.
|
81
|
+
expect(clips).to be_a Kippt::ClipCollection
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -93,7 +93,7 @@ describe Kippt::Clips do
|
|
93
93
|
|
94
94
|
clip = Kippt::Clip.new(:url => "http://kiskolabs.com")
|
95
95
|
response = subject.save_resource(clip)
|
96
|
-
response[:success].
|
96
|
+
expect(response[:success]).to be_truthy
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -105,8 +105,8 @@ describe Kippt::Clips do
|
|
105
105
|
|
106
106
|
clip = Kippt::Clip.new(:url => "http://kiskolabs.com")
|
107
107
|
response = subject.save_resource(clip)
|
108
|
-
response.success
|
109
|
-
response[:error_message].
|
108
|
+
expect(response.success?).to be_falsey
|
109
|
+
expect(response[:error_message]).to eq "No good."
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -142,7 +142,7 @@ describe Kippt::Clips do
|
|
142
142
|
to_return(:status => 200, :headers => {})
|
143
143
|
|
144
144
|
clip = Kippt::Clip.new(:id => 100)
|
145
|
-
subject.destroy_resource(clip).
|
145
|
+
expect(subject.destroy_resource(clip)).to be_truthy
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|