tumblr_client 0.8.4 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tumblr/client.rb +4 -0
- data/lib/tumblr/config.rb +2 -1
- data/lib/tumblr/connection.rb +3 -3
- data/lib/tumblr/version.rb +1 -1
- data/spec/examples/blog_spec.rb +24 -24
- data/spec/examples/client_spec.rb +26 -6
- data/spec/examples/post_spec.rb +36 -36
- data/spec/examples/request_spec.rb +9 -9
- data/spec/examples/tagged_spec.rb +2 -2
- data/spec/examples/user_spec.rb +14 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6f882c0459f4fa220a6e1fabf01e06fea93f0d5
|
4
|
+
data.tar.gz: 6dbefc136aac9e58b6d8a8f74a789f358b17e6a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1082142f48eda16cd1fc58bcf9f406f2b6bc8b3450399cb8d41e01405ed691e86914ee6e89f3f5ba12889e9e8e42b887e65c904a82f1584d3fe2cb79ee33563e
|
7
|
+
data.tar.gz: ac903bc1b8be3373ac5c9f9de917cb3d32cad5993288c3bf1a2ce99e1f176a8de0c8baabfbb8f93df842c8a3779efcfe7f6bc5d18fd9ba87076f6c5056e1f8c8
|
data/lib/tumblr/client.rb
CHANGED
data/lib/tumblr/config.rb
CHANGED
data/lib/tumblr/connection.rb
CHANGED
@@ -12,13 +12,13 @@ module Tumblr
|
|
12
12
|
:accept => 'application/json',
|
13
13
|
:user_agent => "tumblr_client (ruby) - #{Tumblr::VERSION}"
|
14
14
|
},
|
15
|
-
:url => "
|
15
|
+
:url => "#{api_scheme}://#{api_host}/"
|
16
16
|
}
|
17
17
|
|
18
18
|
client = Faraday.default_adapter
|
19
19
|
|
20
|
-
Faraday.new(
|
21
|
-
data = { :api_host => api_host }.merge(credentials)
|
20
|
+
Faraday.new(default_options.merge(options)) do |conn|
|
21
|
+
data = { :api_host => api_host, :ignore_extra_keys => true}.merge(credentials)
|
22
22
|
unless credentials.empty?
|
23
23
|
conn.request :oauth, data
|
24
24
|
end
|
data/lib/tumblr/version.rb
CHANGED
data/spec/examples/blog_spec.rb
CHANGED
@@ -11,19 +11,19 @@ describe Tumblr::Blog do
|
|
11
11
|
describe :blog_info do
|
12
12
|
|
13
13
|
it 'should make the proper request' do
|
14
|
-
client.
|
14
|
+
expect(client).to receive(:get).once.with("v2/blog/#{blog_name}/info", {
|
15
15
|
:api_key => consumer_key
|
16
16
|
}).and_return 'response'
|
17
17
|
r = client.blog_info blog_name
|
18
|
-
r.
|
18
|
+
expect(r).to eq('response')
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should make the proper request with a short blog name' do
|
22
|
-
client.
|
22
|
+
expect(client).to receive(:get).once.with("v2/blog/b.tumblr.com/info", {
|
23
23
|
:api_key => consumer_key
|
24
24
|
}).and_return 'response'
|
25
25
|
r = client.blog_info 'b'
|
26
|
-
r.
|
26
|
+
expect(r).to eq('response')
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
@@ -33,13 +33,13 @@ describe Tumblr::Blog do
|
|
33
33
|
context 'when supplying a size' do
|
34
34
|
|
35
35
|
before do
|
36
|
-
client.
|
36
|
+
expect(client).to receive(:get_redirect_url).once.with("v2/blog/#{blog_name}/avatar/128").
|
37
37
|
and_return('url')
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should construct the request properly' do
|
41
41
|
r = client.avatar blog_name, 128
|
42
|
-
r.
|
42
|
+
expect(r).to eq('url')
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
@@ -47,13 +47,13 @@ describe Tumblr::Blog do
|
|
47
47
|
context 'when no size is specified' do
|
48
48
|
|
49
49
|
before do
|
50
|
-
client.
|
50
|
+
expect(client).to receive(:get_redirect_url).once.with("v2/blog/#{blog_name}/avatar").
|
51
51
|
and_return('url')
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'should construct the request properly' do
|
55
55
|
r = client.avatar blog_name
|
56
|
-
r.
|
56
|
+
expect(r).to eq('url')
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
@@ -65,9 +65,9 @@ describe Tumblr::Blog do
|
|
65
65
|
context 'with invalid parameters' do
|
66
66
|
|
67
67
|
it 'should raise an error' do
|
68
|
-
lambda {
|
68
|
+
expect(lambda {
|
69
69
|
client.followers blog_name, :not => 'an option'
|
70
|
-
}.
|
70
|
+
}).to raise_error ArgumentError
|
71
71
|
end
|
72
72
|
|
73
73
|
end
|
@@ -75,14 +75,14 @@ describe Tumblr::Blog do
|
|
75
75
|
context 'with valid parameters' do
|
76
76
|
|
77
77
|
before do
|
78
|
-
client.
|
78
|
+
expect(client).to receive(:get).once.with("v2/blog/#{blog_name}/followers", {
|
79
79
|
:limit => 1
|
80
80
|
}).and_return('response')
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'should construct the request properly' do
|
84
84
|
r = client.followers blog_name, :limit => 1
|
85
|
-
r.
|
85
|
+
expect(r).to eq'response'
|
86
86
|
end
|
87
87
|
|
88
88
|
end
|
@@ -94,9 +94,9 @@ describe Tumblr::Blog do
|
|
94
94
|
context 'with invalid parameters' do
|
95
95
|
|
96
96
|
it 'should raise an error' do
|
97
|
-
lambda {
|
97
|
+
expect(lambda {
|
98
98
|
client.blog_likes blog_name, :not => 'an option'
|
99
|
-
}.
|
99
|
+
}).to raise_error ArgumentError
|
100
100
|
end
|
101
101
|
|
102
102
|
end
|
@@ -104,7 +104,7 @@ describe Tumblr::Blog do
|
|
104
104
|
context 'with valid parameters' do
|
105
105
|
|
106
106
|
before do
|
107
|
-
client.
|
107
|
+
expect(client).to receive(:get).once.with("v2/blog/#{blog_name}/likes", {
|
108
108
|
:limit => 1,
|
109
109
|
:api_key => consumer_key
|
110
110
|
}).and_return('response')
|
@@ -112,7 +112,7 @@ describe Tumblr::Blog do
|
|
112
112
|
|
113
113
|
it 'should construct the request properly' do
|
114
114
|
r = client.blog_likes blog_name, :limit => 1
|
115
|
-
r.
|
115
|
+
expect(r).to eq('response')
|
116
116
|
end
|
117
117
|
|
118
118
|
end
|
@@ -124,7 +124,7 @@ describe Tumblr::Blog do
|
|
124
124
|
context 'without a type supplied' do
|
125
125
|
|
126
126
|
before do
|
127
|
-
client.
|
127
|
+
expect(client).to receive(:get).once.with("v2/blog/#{blog_name}/posts", {
|
128
128
|
:limit => 1,
|
129
129
|
:api_key => consumer_key
|
130
130
|
}).and_return('response')
|
@@ -132,7 +132,7 @@ describe Tumblr::Blog do
|
|
132
132
|
|
133
133
|
it 'should construct the request properly' do
|
134
134
|
r = client.posts blog_name, :limit => 1
|
135
|
-
r.
|
135
|
+
expect(r).to eq('response')
|
136
136
|
end
|
137
137
|
|
138
138
|
end
|
@@ -140,7 +140,7 @@ describe Tumblr::Blog do
|
|
140
140
|
context 'when supplying a type' do
|
141
141
|
|
142
142
|
before do
|
143
|
-
client.
|
143
|
+
expect(client).to receive(:get).once.with("v2/blog/#{blog_name}/posts/audio", {
|
144
144
|
:limit => 1,
|
145
145
|
:api_key => consumer_key,
|
146
146
|
:type => 'audio'
|
@@ -149,7 +149,7 @@ describe Tumblr::Blog do
|
|
149
149
|
|
150
150
|
it 'should construct the request properly' do
|
151
151
|
r = client.posts blog_name, :limit => 1, :type => 'audio'
|
152
|
-
r.
|
152
|
+
expect(r).to eq('response')
|
153
153
|
end
|
154
154
|
|
155
155
|
end
|
@@ -166,9 +166,9 @@ describe Tumblr::Blog do
|
|
166
166
|
context 'when using parameters other than limit & offset' do
|
167
167
|
|
168
168
|
it 'should raise an error' do
|
169
|
-
lambda {
|
169
|
+
expect(lambda {
|
170
170
|
client.send type, blog_name, :not => 'an option'
|
171
|
-
}.
|
171
|
+
}).to raise_error ArgumentError
|
172
172
|
end
|
173
173
|
|
174
174
|
end
|
@@ -177,11 +177,11 @@ describe Tumblr::Blog do
|
|
177
177
|
|
178
178
|
it 'should construct the call properly' do
|
179
179
|
limit = 5
|
180
|
-
client.
|
180
|
+
expect(client).to receive(:get).once.with("v2/blog/#{blog_name}/posts/#{ext}", {
|
181
181
|
:limit => limit
|
182
182
|
}).and_return('response')
|
183
183
|
r = client.send type, blog_name, :limit => limit
|
184
|
-
r.
|
184
|
+
expect(r).to eq('response')
|
185
185
|
end
|
186
186
|
|
187
187
|
end
|
@@ -13,16 +13,16 @@ describe Tumblr::Client do
|
|
13
13
|
|
14
14
|
it 'should give new clients those credentials' do
|
15
15
|
client = Tumblr::Client.new
|
16
|
-
client.credentials[:consumer_key].
|
16
|
+
expect(client.credentials[:consumer_key]).to eq(@key)
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should have it\'s own credentials' do
|
20
|
-
Tumblr.credentials[:consumer_key].
|
20
|
+
expect(Tumblr.credentials[:consumer_key]).to eq(@key)
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should be able to make a new client (using these credentials)' do
|
24
|
-
Tumblr.new.
|
25
|
-
Tumblr.new.credentials[:consumer_key].
|
24
|
+
expect(Tumblr.new).to be_a(Tumblr::Client)
|
25
|
+
expect(Tumblr.new.credentials[:consumer_key]).to eq(@key)
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
@@ -35,10 +35,30 @@ describe Tumblr::Client do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'should keep them separate' do
|
38
|
-
[
|
38
|
+
expect([
|
39
39
|
@client1.credentials[:consumer_key],
|
40
40
|
@client2.credentials[:consumer_key]
|
41
|
-
].uniq.count.
|
41
|
+
].uniq.count).to eq(2)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe :api_scheme do
|
47
|
+
|
48
|
+
it 'defaults to https' do
|
49
|
+
expect(Tumblr::Client.new.api_scheme).to eq('https')
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'can be set by the initializer' do
|
53
|
+
client = Tumblr::Client.new(:api_scheme => 'http')
|
54
|
+
expect(client.api_scheme).to eq('http')
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'can be set globally' do
|
58
|
+
Tumblr.configure do |c|
|
59
|
+
c.api_scheme = 'http'
|
60
|
+
end
|
61
|
+
expect(Tumblr::Client.new.api_scheme).to eq('http')
|
42
62
|
end
|
43
63
|
|
44
64
|
end
|
data/spec/examples/post_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe Tumblr::Post do
|
|
14
14
|
context 'when deleting a post' do
|
15
15
|
|
16
16
|
before do
|
17
|
-
client.
|
17
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post/delete", {
|
18
18
|
:id => post_id
|
19
19
|
})
|
20
20
|
end
|
@@ -33,8 +33,8 @@ describe Tumblr::Post do
|
|
33
33
|
context 'when passing data as an array of filepaths' do
|
34
34
|
before do
|
35
35
|
fakefile = OpenStruct.new :read => file_data
|
36
|
-
File.
|
37
|
-
client.
|
36
|
+
allow(File).to receive(:open).with(file_path + '.jpg').and_return(fakefile)
|
37
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post/edit", {
|
38
38
|
'data[0]' => kind_of(Faraday::UploadIO),
|
39
39
|
:id => 123,
|
40
40
|
:type => type
|
@@ -43,12 +43,12 @@ describe Tumblr::Post do
|
|
43
43
|
|
44
44
|
it 'should be able to pass data as an array of filepaths' do
|
45
45
|
r = client.edit blog_name, :data => [file_path + ".jpg"], :id => 123, :type => type
|
46
|
-
r.
|
46
|
+
expect(r).to eq('response')
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should be able to pass data as an array of uploadios' do
|
50
50
|
r = client.edit blog_name, :data => [Faraday::UploadIO.new(StringIO.new, 'image/jpeg')], :id => 123, :type => type
|
51
|
-
r.
|
51
|
+
expect(r).to eq('response')
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|
@@ -57,8 +57,8 @@ describe Tumblr::Post do
|
|
57
57
|
|
58
58
|
before do
|
59
59
|
fakefile = OpenStruct.new :read => file_data
|
60
|
-
File.
|
61
|
-
client.
|
60
|
+
allow(File).to receive(:open).with(file_path + '.jpg').and_return(fakefile)
|
61
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post/edit", {
|
62
62
|
'data' => kind_of(Faraday::UploadIO),
|
63
63
|
:id => 123,
|
64
64
|
:type => type
|
@@ -67,12 +67,12 @@ describe Tumblr::Post do
|
|
67
67
|
|
68
68
|
it 'should be able to pass data as a single filepath' do
|
69
69
|
r = client.edit blog_name, :data => file_path + ".jpg", :id => 123, :type => type
|
70
|
-
r.
|
70
|
+
expect(r).to eq('response')
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should be able to pass data as a single uploadio' do
|
74
74
|
r = client.edit blog_name, :data => Faraday::UploadIO.new(StringIO.new, 'image/jpeg'), :id => 123, :type => type
|
75
|
-
r.
|
75
|
+
expect(r).to eq('response')
|
76
76
|
end
|
77
77
|
|
78
78
|
end
|
@@ -80,22 +80,22 @@ describe Tumblr::Post do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'should make the correct call' do
|
83
|
-
client.
|
83
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post/edit", {
|
84
84
|
:id => 123
|
85
85
|
}).and_return('response')
|
86
86
|
r = client.edit blog_name, :id => 123
|
87
|
-
r.
|
87
|
+
expect(r).to eq('response')
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
describe :reblog do
|
92
92
|
|
93
93
|
it 'should make the correct call' do
|
94
|
-
client.
|
94
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post/reblog", {
|
95
95
|
:id => 123
|
96
96
|
}).and_return('response')
|
97
97
|
r = client.reblog blog_name, :id => 123
|
98
|
-
r.
|
98
|
+
expect(r).to eq('response')
|
99
99
|
end
|
100
100
|
|
101
101
|
end
|
@@ -110,9 +110,9 @@ describe Tumblr::Post do
|
|
110
110
|
context 'when passing an option which is not allowed' do
|
111
111
|
|
112
112
|
it 'should raise an error' do
|
113
|
-
lambda {
|
113
|
+
expect(lambda {
|
114
114
|
client.send type, blog_name, :not => 'an option'
|
115
|
-
}.
|
115
|
+
}).to raise_error ArgumentError
|
116
116
|
end
|
117
117
|
|
118
118
|
end
|
@@ -121,7 +121,7 @@ describe Tumblr::Post do
|
|
121
121
|
|
122
122
|
before do
|
123
123
|
@val = 'hello world'
|
124
|
-
client.
|
124
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post", {
|
125
125
|
field.to_sym => @val,
|
126
126
|
:type => type.to_s
|
127
127
|
}).and_return('response')
|
@@ -129,7 +129,7 @@ describe Tumblr::Post do
|
|
129
129
|
|
130
130
|
it 'should set up the call properly' do
|
131
131
|
r = client.send type, blog_name, field.to_sym => @val
|
132
|
-
r.
|
132
|
+
expect(r).to eq('response')
|
133
133
|
end
|
134
134
|
|
135
135
|
end
|
@@ -146,11 +146,11 @@ describe Tumblr::Post do
|
|
146
146
|
context 'with a valid post type' do
|
147
147
|
|
148
148
|
before do
|
149
|
-
client.
|
149
|
+
expect(client).to receive(:photo).with(blog_name, args).and_return 'hi'
|
150
150
|
end
|
151
151
|
|
152
152
|
it 'should call the right method and grab the return' do
|
153
|
-
client.create_post(:photo, blog_name, args).
|
153
|
+
expect(client.create_post(:photo, blog_name, args)).to eq('hi')
|
154
154
|
end
|
155
155
|
|
156
156
|
end
|
@@ -158,9 +158,9 @@ describe Tumblr::Post do
|
|
158
158
|
context 'with an invalid post type' do
|
159
159
|
|
160
160
|
it 'should raise an error' do
|
161
|
-
lambda do
|
161
|
+
expect(lambda do
|
162
162
|
client.create_post(:fake, blog_name, args)
|
163
|
-
end.
|
163
|
+
end).to raise_error ArgumentError, '"fake" is not a valid post type'
|
164
164
|
end
|
165
165
|
|
166
166
|
end
|
@@ -175,9 +175,9 @@ describe Tumblr::Post do
|
|
175
175
|
context 'when passing an option which is not allowed' do
|
176
176
|
|
177
177
|
it 'should raise an error' do
|
178
|
-
lambda {
|
178
|
+
expect(lambda {
|
179
179
|
client.send type, blog_name, :not => 'an option'
|
180
|
-
}.
|
180
|
+
}).to raise_error ArgumentError
|
181
181
|
end
|
182
182
|
|
183
183
|
end
|
@@ -185,8 +185,8 @@ describe Tumblr::Post do
|
|
185
185
|
context 'when passing data as an array of filepaths' do
|
186
186
|
before do
|
187
187
|
fakefile = OpenStruct.new :read => file_data
|
188
|
-
File.
|
189
|
-
client.
|
188
|
+
allow(File).to receive(:open).with(file_path + '.jpg').and_return(fakefile)
|
189
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post", {
|
190
190
|
'data[0]' => kind_of(Faraday::UploadIO),
|
191
191
|
:type => type.to_s
|
192
192
|
}).and_return('post')
|
@@ -194,12 +194,12 @@ describe Tumblr::Post do
|
|
194
194
|
|
195
195
|
it 'should be able to pass data as an array of filepaths' do
|
196
196
|
r = client.send type, blog_name, :data => [file_path + ".jpg"]
|
197
|
-
r.
|
197
|
+
expect(r).to eq('post')
|
198
198
|
end
|
199
199
|
|
200
200
|
it 'should be able to pass data as an array of uploadios' do
|
201
201
|
r = client.send type, blog_name, :data => [Faraday::UploadIO.new(StringIO.new, 'image/jpeg')]
|
202
|
-
r.
|
202
|
+
expect(r).to eq('post')
|
203
203
|
end
|
204
204
|
|
205
205
|
end
|
@@ -208,8 +208,8 @@ describe Tumblr::Post do
|
|
208
208
|
|
209
209
|
before do
|
210
210
|
fakefile = OpenStruct.new :read => file_data
|
211
|
-
File.
|
212
|
-
client.
|
211
|
+
allow(File).to receive(:open).with(file_path + '.jpg').and_return(fakefile)
|
212
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post", {
|
213
213
|
'data' => kind_of(Faraday::UploadIO),
|
214
214
|
:type => type.to_s
|
215
215
|
}).and_return('post')
|
@@ -217,12 +217,12 @@ describe Tumblr::Post do
|
|
217
217
|
|
218
218
|
it 'should be able to pass data as a single filepath' do
|
219
219
|
r = client.send type, blog_name, :data => file_path + ".jpg"
|
220
|
-
r.
|
220
|
+
expect(r).to eq('post')
|
221
221
|
end
|
222
222
|
|
223
223
|
it 'should be able to pass data as a single uploadio' do
|
224
224
|
r = client.send type, blog_name, :data => Faraday::UploadIO.new(StringIO.new, 'image/jpeg')
|
225
|
-
r.
|
225
|
+
expect(r).to eq('post')
|
226
226
|
end
|
227
227
|
|
228
228
|
end
|
@@ -233,7 +233,7 @@ describe Tumblr::Post do
|
|
233
233
|
context 'when passing source different ways' do
|
234
234
|
|
235
235
|
it 'should be able to be passed as a string' do
|
236
|
-
client.
|
236
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post", {
|
237
237
|
:source => source,
|
238
238
|
:type => type.to_s
|
239
239
|
})
|
@@ -241,7 +241,7 @@ describe Tumblr::Post do
|
|
241
241
|
end
|
242
242
|
|
243
243
|
it 'should be able to be passed as an array' do
|
244
|
-
client.
|
244
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post", {
|
245
245
|
'source[0]' => source,
|
246
246
|
'source[1]' => source,
|
247
247
|
:type => type.to_s
|
@@ -250,7 +250,7 @@ describe Tumblr::Post do
|
|
250
250
|
end
|
251
251
|
|
252
252
|
it 'should be able to be passed as an array on edit' do
|
253
|
-
client.
|
253
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post/edit", {
|
254
254
|
:id => post_id,
|
255
255
|
'source[0]' => source,
|
256
256
|
'source[1]' => source
|
@@ -265,9 +265,9 @@ describe Tumblr::Post do
|
|
265
265
|
context 'when passing colliding options' do
|
266
266
|
|
267
267
|
it 'should get an error when passing data & source' do
|
268
|
-
lambda {
|
268
|
+
expect(lambda {
|
269
269
|
client.send type, blog_name, :data => 'hi', :source => 'bye'
|
270
|
-
}.
|
270
|
+
}).to raise_error ArgumentError
|
271
271
|
end
|
272
272
|
|
273
273
|
end
|
@@ -13,7 +13,7 @@ describe Tumblr::Request do
|
|
13
13
|
it 'should return the meta object' do
|
14
14
|
data = { :message => 'ohyes' }
|
15
15
|
response = OpenStruct.new(:status => rcode, :body => { 'response' => data })
|
16
|
-
client.respond(response).
|
16
|
+
expect(client.respond(response)).to eq(data)
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -25,13 +25,13 @@ describe Tumblr::Request do
|
|
25
25
|
it 'should return the meta object (merged with response)' do
|
26
26
|
meta = { :message => 'ohno' }
|
27
27
|
response = OpenStruct.new(:status => 401, :body => { 'meta' => meta, 'response' => { :also => 'hi' } })
|
28
|
-
client.respond(response).
|
28
|
+
expect(client.respond(response)).to eq({ :message => 'ohno', :also => 'hi' })
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should return the meta object even when response is nil' do
|
32
32
|
meta = { :message => 'ohno' }
|
33
33
|
response = OpenStruct.new(:status => 401, :body => { 'meta' => meta, 'response' => nil })
|
34
|
-
client.respond(response).
|
34
|
+
expect(client.respond(response)).to eq(meta)
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -43,7 +43,7 @@ describe Tumblr::Request do
|
|
43
43
|
before do
|
44
44
|
@path = '/the/path'
|
45
45
|
@params = { :hello => 'world' }
|
46
|
-
client.
|
46
|
+
expect(client).to receive(:get_response).once.with(@path, @params).
|
47
47
|
and_return(OpenStruct.new({
|
48
48
|
:status => 200,
|
49
49
|
:body => { 'response' => 'result' }
|
@@ -51,7 +51,7 @@ describe Tumblr::Request do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'should get the response directly' do
|
54
|
-
client.get(@path, @params).
|
54
|
+
expect(client.get(@path, @params)).to eq('result')
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
@@ -64,7 +64,7 @@ describe Tumblr::Request do
|
|
64
64
|
@path = '/the/path'
|
65
65
|
@params = { :hello => 'world' }
|
66
66
|
@redirect_url = 'redirect-to-here'
|
67
|
-
client.
|
67
|
+
expect(client).to receive(:get_response).once.with(@path, @params).
|
68
68
|
and_return(OpenStruct.new({
|
69
69
|
:status => 301,
|
70
70
|
:headers => { 'Location' => @redirect_url }
|
@@ -72,7 +72,7 @@ describe Tumblr::Request do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'should return the redirect url' do
|
75
|
-
client.get_redirect_url(@path, @params).
|
75
|
+
expect(client.get_redirect_url(@path, @params)).to eq(@redirect_url)
|
76
76
|
end
|
77
77
|
|
78
78
|
end
|
@@ -83,7 +83,7 @@ describe Tumblr::Request do
|
|
83
83
|
@path = '/the/path'
|
84
84
|
@params = { :hello => 'world' }
|
85
85
|
@meta = { :message => 'ohno' }
|
86
|
-
client.
|
86
|
+
expect(client).to receive(:get_response).once.with(@path, @params).
|
87
87
|
and_return(OpenStruct.new({
|
88
88
|
:status => 401,
|
89
89
|
:body => { 'meta' => @meta }
|
@@ -91,7 +91,7 @@ describe Tumblr::Request do
|
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'should return the error meta' do
|
94
|
-
client.get_redirect_url(@path, @params).
|
94
|
+
expect(client.get_redirect_url(@path, @params)).to eq(@meta)
|
95
95
|
end
|
96
96
|
|
97
97
|
end
|
@@ -15,7 +15,7 @@ describe Tumblr::Tagged do
|
|
15
15
|
describe :tagged do
|
16
16
|
|
17
17
|
before do
|
18
|
-
client.
|
18
|
+
expect(client).to receive(:get).once.with('v2/tagged', {
|
19
19
|
:tag => tag,
|
20
20
|
:api_key => consumer_key
|
21
21
|
}).and_return('response')
|
@@ -23,7 +23,7 @@ describe Tumblr::Tagged do
|
|
23
23
|
|
24
24
|
it 'should setup the request properly' do
|
25
25
|
r = client.tagged tag
|
26
|
-
r.
|
26
|
+
expect(r).to eq('response')
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
data/spec/examples/user_spec.rb
CHANGED
@@ -7,9 +7,9 @@ describe Tumblr::User do
|
|
7
7
|
describe :info do
|
8
8
|
|
9
9
|
it 'should make the request properly' do
|
10
|
-
client.
|
10
|
+
expect(client).to receive(:get).with('v2/user/info').and_return('response')
|
11
11
|
r = client.info
|
12
|
-
r.
|
12
|
+
expect(r).to eq('response')
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
@@ -19,9 +19,9 @@ describe Tumblr::User do
|
|
19
19
|
context 'when using options that are not allowed' do
|
20
20
|
|
21
21
|
it 'should raise an error' do
|
22
|
-
lambda {
|
22
|
+
expect(lambda {
|
23
23
|
client.dashboard :not => 'an option'
|
24
|
-
}.
|
24
|
+
}).to raise_error ArgumentError
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -29,11 +29,11 @@ describe Tumblr::User do
|
|
29
29
|
context 'when using valid options' do
|
30
30
|
|
31
31
|
it 'should make the correct call' do
|
32
|
-
client.
|
32
|
+
expect(client).to receive(:get).with('v2/user/dashboard', {
|
33
33
|
:limit => 25
|
34
34
|
}).and_return('response')
|
35
35
|
r = client.dashboard :limit => 25
|
36
|
-
r.
|
36
|
+
expect(r).to eq('response')
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|
@@ -48,10 +48,10 @@ describe Tumblr::User do
|
|
48
48
|
context 'with defaults' do
|
49
49
|
|
50
50
|
it 'should make the reqest properly' do
|
51
|
-
client.
|
51
|
+
expect(client).to receive(:get).with("v2/user/#{type}", {}).
|
52
52
|
and_return('response')
|
53
53
|
r = client.send type
|
54
|
-
r.
|
54
|
+
expect(r).to eq('response')
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
@@ -59,12 +59,12 @@ describe Tumblr::User do
|
|
59
59
|
context 'with custom limit & offset' do
|
60
60
|
|
61
61
|
it 'should make the reqest properly' do
|
62
|
-
client.
|
62
|
+
expect(client).to receive(:get).with("v2/user/#{type}", {
|
63
63
|
:limit => 10,
|
64
64
|
:offset => 5
|
65
65
|
}).and_return('response')
|
66
66
|
r = client.send type, :offset => 5, :limit => 10
|
67
|
-
r.
|
67
|
+
expect(r).to eq('response')
|
68
68
|
end
|
69
69
|
|
70
70
|
end
|
@@ -81,12 +81,12 @@ describe Tumblr::User do
|
|
81
81
|
it 'should make the request properly' do
|
82
82
|
id = 123
|
83
83
|
reblog_key = 'hello'
|
84
|
-
client.
|
84
|
+
expect(client).to receive(:post).with("v2/user/#{type}", {
|
85
85
|
:id => id,
|
86
86
|
:reblog_key => reblog_key
|
87
87
|
}).and_return('response')
|
88
88
|
r = client.send type, id, reblog_key
|
89
|
-
r.
|
89
|
+
expect(r).to eq('response')
|
90
90
|
end
|
91
91
|
|
92
92
|
end
|
@@ -100,11 +100,11 @@ describe Tumblr::User do
|
|
100
100
|
|
101
101
|
it 'should make the request properly' do
|
102
102
|
url = 'some url'
|
103
|
-
client.
|
103
|
+
expect(client).to receive(:post).with("v2/user/#{type}", {
|
104
104
|
:url => url
|
105
105
|
}).and_return('response')
|
106
106
|
r = client.send type, url
|
107
|
-
r.
|
107
|
+
expect(r).to eq('response')
|
108
108
|
end
|
109
109
|
|
110
110
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tumblr_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bunting
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-12-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|