doomy_client 0.8.5
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.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +11 -0
- data/CONTRIBUTING.md +22 -0
- data/Gemfile +3 -0
- data/LICENSE +202 -0
- data/README.md +107 -0
- data/Rakefile +23 -0
- data/bin/tumblr +80 -0
- data/lib/tumblr/blog.rb +59 -0
- data/lib/tumblr/client.rb +51 -0
- data/lib/tumblr/config.rb +36 -0
- data/lib/tumblr/connection.rb +33 -0
- data/lib/tumblr/helpers.rb +29 -0
- data/lib/tumblr/post.rb +147 -0
- data/lib/tumblr/request.rb +54 -0
- data/lib/tumblr/tagged.rb +13 -0
- data/lib/tumblr/user.rb +41 -0
- data/lib/tumblr/version.rb +5 -0
- data/lib/tumblr_client.rb +16 -0
- data/spec/examples/blog_spec.rb +193 -0
- data/spec/examples/client_spec.rb +66 -0
- data/spec/examples/post_spec.rb +279 -0
- data/spec/examples/request_spec.rb +101 -0
- data/spec/examples/tagged_spec.rb +31 -0
- data/spec/examples/user_spec.rb +114 -0
- data/spec/spec_helper.rb +7 -0
- data/tumblr_client.gemspec +27 -0
- metadata +216 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'tumblr/client'
|
|
2
|
+
require 'tumblr/config'
|
|
3
|
+
|
|
4
|
+
module Tumblr
|
|
5
|
+
|
|
6
|
+
autoload :VERSION, File.join(File.dirname(__FILE__), 'tumblr/version')
|
|
7
|
+
|
|
8
|
+
extend Config
|
|
9
|
+
|
|
10
|
+
class << self
|
|
11
|
+
def new(options={})
|
|
12
|
+
Tumblr::Client.new(options)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Tumblr::Blog do
|
|
4
|
+
|
|
5
|
+
let(:blog_name) { 'seejohnrun.tumblr.com' }
|
|
6
|
+
let(:consumer_key) { 'ckey' }
|
|
7
|
+
let(:client) do
|
|
8
|
+
Tumblr::Client.new :consumer_key => consumer_key
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe :blog_info do
|
|
12
|
+
|
|
13
|
+
it 'should make the proper request' do
|
|
14
|
+
expect(client).to receive(:get).once.with("v2/blog/#{blog_name}/info", {
|
|
15
|
+
:api_key => consumer_key
|
|
16
|
+
}).and_return 'response'
|
|
17
|
+
r = client.blog_info blog_name
|
|
18
|
+
expect(r).to eq('response')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should make the proper request with a short blog name' do
|
|
22
|
+
expect(client).to receive(:get).once.with("v2/blog/b.tumblr.com/info", {
|
|
23
|
+
:api_key => consumer_key
|
|
24
|
+
}).and_return 'response'
|
|
25
|
+
r = client.blog_info 'b'
|
|
26
|
+
expect(r).to eq('response')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe :avatar do
|
|
32
|
+
|
|
33
|
+
context 'when supplying a size' do
|
|
34
|
+
|
|
35
|
+
before do
|
|
36
|
+
expect(client).to receive(:get_redirect_url).once.with("v2/blog/#{blog_name}/avatar/128").
|
|
37
|
+
and_return('url')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'should construct the request properly' do
|
|
41
|
+
r = client.avatar blog_name, 128
|
|
42
|
+
expect(r).to eq('url')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context 'when no size is specified' do
|
|
48
|
+
|
|
49
|
+
before do
|
|
50
|
+
expect(client).to receive(:get_redirect_url).once.with("v2/blog/#{blog_name}/avatar").
|
|
51
|
+
and_return('url')
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should construct the request properly' do
|
|
55
|
+
r = client.avatar blog_name
|
|
56
|
+
expect(r).to eq('url')
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe :followers do
|
|
64
|
+
|
|
65
|
+
context 'with invalid parameters' do
|
|
66
|
+
|
|
67
|
+
it 'should raise an error' do
|
|
68
|
+
expect(lambda {
|
|
69
|
+
client.followers blog_name, :not => 'an option'
|
|
70
|
+
}).to raise_error ArgumentError
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
context 'with valid parameters' do
|
|
76
|
+
|
|
77
|
+
before do
|
|
78
|
+
expect(client).to receive(:get).once.with("v2/blog/#{blog_name}/followers", {
|
|
79
|
+
:limit => 1
|
|
80
|
+
}).and_return('response')
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'should construct the request properly' do
|
|
84
|
+
r = client.followers blog_name, :limit => 1
|
|
85
|
+
expect(r).to eq'response'
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe :blog_likes do
|
|
93
|
+
|
|
94
|
+
context 'with invalid parameters' do
|
|
95
|
+
|
|
96
|
+
it 'should raise an error' do
|
|
97
|
+
expect(lambda {
|
|
98
|
+
client.blog_likes blog_name, :not => 'an option'
|
|
99
|
+
}).to raise_error ArgumentError
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
context 'with valid parameters' do
|
|
105
|
+
|
|
106
|
+
before do
|
|
107
|
+
expect(client).to receive(:get).once.with("v2/blog/#{blog_name}/likes", {
|
|
108
|
+
:limit => 1,
|
|
109
|
+
:api_key => consumer_key
|
|
110
|
+
}).and_return('response')
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'should construct the request properly' do
|
|
114
|
+
r = client.blog_likes blog_name, :limit => 1
|
|
115
|
+
expect(r).to eq('response')
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
describe :posts do
|
|
123
|
+
|
|
124
|
+
context 'without a type supplied' do
|
|
125
|
+
|
|
126
|
+
before do
|
|
127
|
+
expect(client).to receive(:get).once.with("v2/blog/#{blog_name}/posts", {
|
|
128
|
+
:limit => 1,
|
|
129
|
+
:api_key => consumer_key
|
|
130
|
+
}).and_return('response')
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it 'should construct the request properly' do
|
|
134
|
+
r = client.posts blog_name, :limit => 1
|
|
135
|
+
expect(r).to eq('response')
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
context 'when supplying a type' do
|
|
141
|
+
|
|
142
|
+
before do
|
|
143
|
+
expect(client).to receive(:get).once.with("v2/blog/#{blog_name}/posts/audio", {
|
|
144
|
+
:limit => 1,
|
|
145
|
+
:api_key => consumer_key,
|
|
146
|
+
:type => 'audio'
|
|
147
|
+
}).and_return('response')
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
it 'should construct the request properly' do
|
|
151
|
+
r = client.posts blog_name, :limit => 1, :type => 'audio'
|
|
152
|
+
expect(r).to eq('response')
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# These are all just lists of posts with pagination
|
|
160
|
+
[:queue, :draft, :submissions].each do |type|
|
|
161
|
+
|
|
162
|
+
ext = type == :submissions ? 'submission' : type.to_s # annoying
|
|
163
|
+
|
|
164
|
+
describe type do
|
|
165
|
+
|
|
166
|
+
context 'when using parameters other than limit & offset' do
|
|
167
|
+
|
|
168
|
+
it 'should raise an error' do
|
|
169
|
+
expect(lambda {
|
|
170
|
+
client.send type, blog_name, :not => 'an option'
|
|
171
|
+
}).to raise_error ArgumentError
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
context 'with valid options' do
|
|
177
|
+
|
|
178
|
+
it 'should construct the call properly' do
|
|
179
|
+
limit = 5
|
|
180
|
+
expect(client).to receive(:get).once.with("v2/blog/#{blog_name}/posts/#{ext}", {
|
|
181
|
+
:limit => limit
|
|
182
|
+
}).and_return('response')
|
|
183
|
+
r = client.send type, blog_name, :limit => limit
|
|
184
|
+
expect(r).to eq('response')
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Tumblr::Client do
|
|
4
|
+
|
|
5
|
+
context 'when using the generic copy' do
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
@key = 'thekey'
|
|
9
|
+
Tumblr.configure do |c|
|
|
10
|
+
c.consumer_key = @key
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should give new clients those credentials' do
|
|
15
|
+
client = Tumblr::Client.new
|
|
16
|
+
expect(client.credentials[:consumer_key]).to eq(@key)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should have it\'s own credentials' do
|
|
20
|
+
expect(Tumblr.credentials[:consumer_key]).to eq(@key)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'should be able to make a new client (using these credentials)' do
|
|
24
|
+
expect(Tumblr.new).to be_a(Tumblr::Client)
|
|
25
|
+
expect(Tumblr.new.credentials[:consumer_key]).to eq(@key)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context 'when using custom copies of the client' do
|
|
31
|
+
|
|
32
|
+
before do
|
|
33
|
+
@client1 = Tumblr::Client.new(:consumer_key => 'key1')
|
|
34
|
+
@client2 = Tumblr::Client.new(:consumer_key => 'key2')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should keep them separate' do
|
|
38
|
+
expect([
|
|
39
|
+
@client1.credentials[:consumer_key],
|
|
40
|
+
@client2.credentials[:consumer_key]
|
|
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')
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Tumblr::Post do
|
|
4
|
+
|
|
5
|
+
let(:client) { Tumblr::Client.new }
|
|
6
|
+
let(:blog_name) { 'blog.name' }
|
|
7
|
+
let(:file_path) { '/path/to/the/file' }
|
|
8
|
+
let(:file_data) { 'lol cats' }
|
|
9
|
+
let(:source) { 'the source' }
|
|
10
|
+
let(:post_id) { 42 }
|
|
11
|
+
|
|
12
|
+
describe :delete do
|
|
13
|
+
|
|
14
|
+
context 'when deleting a post' do
|
|
15
|
+
|
|
16
|
+
before do
|
|
17
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post/delete", {
|
|
18
|
+
:id => post_id
|
|
19
|
+
})
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'should setup a delete properly' do
|
|
23
|
+
client.delete blog_name, post_id
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe :edit do
|
|
31
|
+
[:photo, :audio, :video].each do |type|
|
|
32
|
+
describe type do
|
|
33
|
+
context 'when passing data as an array of filepaths' do
|
|
34
|
+
before do
|
|
35
|
+
fakefile = OpenStruct.new :read => file_data
|
|
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
|
+
'data[0]' => kind_of(Faraday::UploadIO),
|
|
39
|
+
:id => 123,
|
|
40
|
+
:type => type
|
|
41
|
+
}).and_return('response')
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'should be able to pass data as an array of filepaths' do
|
|
45
|
+
r = client.edit blog_name, :data => [file_path + ".jpg"], :id => 123, :type => type
|
|
46
|
+
expect(r).to eq('response')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should be able to pass data as an array of uploadios' do
|
|
50
|
+
r = client.edit blog_name, :data => [Faraday::UploadIO.new(StringIO.new, 'image/jpeg')], :id => 123, :type => type
|
|
51
|
+
expect(r).to eq('response')
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'when passing data different ways' do
|
|
57
|
+
|
|
58
|
+
before do
|
|
59
|
+
fakefile = OpenStruct.new :read => file_data
|
|
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
|
+
'data' => kind_of(Faraday::UploadIO),
|
|
63
|
+
:id => 123,
|
|
64
|
+
:type => type
|
|
65
|
+
}).and_return('response')
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'should be able to pass data as a single filepath' do
|
|
69
|
+
r = client.edit blog_name, :data => file_path + ".jpg", :id => 123, :type => type
|
|
70
|
+
expect(r).to eq('response')
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'should be able to pass data as a single uploadio' do
|
|
74
|
+
r = client.edit blog_name, :data => Faraday::UploadIO.new(StringIO.new, 'image/jpeg'), :id => 123, :type => type
|
|
75
|
+
expect(r).to eq('response')
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'should make the correct call' do
|
|
83
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post/edit", {
|
|
84
|
+
:id => 123
|
|
85
|
+
}).and_return('response')
|
|
86
|
+
r = client.edit blog_name, :id => 123
|
|
87
|
+
expect(r).to eq('response')
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
describe :reblog do
|
|
92
|
+
|
|
93
|
+
it 'should make the correct call' do
|
|
94
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post/reblog", {
|
|
95
|
+
:id => 123
|
|
96
|
+
}).and_return('response')
|
|
97
|
+
r = client.reblog blog_name, :id => 123
|
|
98
|
+
expect(r).to eq('response')
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Simple post types
|
|
104
|
+
[:quote, :text, :link, :chat].each do |type|
|
|
105
|
+
|
|
106
|
+
field = type == :quote ? 'quote' : 'title' # uglay
|
|
107
|
+
|
|
108
|
+
describe type do
|
|
109
|
+
|
|
110
|
+
context 'when passing an option which is not allowed' do
|
|
111
|
+
|
|
112
|
+
it 'should raise an error' do
|
|
113
|
+
expect(lambda {
|
|
114
|
+
client.send type, blog_name, :not => 'an option'
|
|
115
|
+
}).to raise_error ArgumentError
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
context 'when passing valid data' do
|
|
121
|
+
|
|
122
|
+
before do
|
|
123
|
+
@val = 'hello world'
|
|
124
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post", {
|
|
125
|
+
field.to_sym => @val,
|
|
126
|
+
:type => type.to_s
|
|
127
|
+
}).and_return('response')
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it 'should set up the call properly' do
|
|
131
|
+
r = client.send type, blog_name, field.to_sym => @val
|
|
132
|
+
expect(r).to eq('response')
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
describe :create_post do
|
|
142
|
+
|
|
143
|
+
let(:blog_name) { 'seejohnrun' }
|
|
144
|
+
let(:args) { { :source => 'somesource' } }
|
|
145
|
+
|
|
146
|
+
context 'with a valid post type' do
|
|
147
|
+
|
|
148
|
+
before do
|
|
149
|
+
expect(client).to receive(:photo).with(blog_name, args).and_return 'hi'
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
it 'should call the right method and grab the return' do
|
|
153
|
+
expect(client.create_post(:photo, blog_name, args)).to eq('hi')
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
context 'with an invalid post type' do
|
|
159
|
+
|
|
160
|
+
it 'should raise an error' do
|
|
161
|
+
expect(lambda do
|
|
162
|
+
client.create_post(:fake, blog_name, args)
|
|
163
|
+
end).to raise_error ArgumentError, '"fake" is not a valid post type'
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Complex post types
|
|
171
|
+
[:photo, :audio, :video].each do |type|
|
|
172
|
+
|
|
173
|
+
describe type do
|
|
174
|
+
|
|
175
|
+
context 'when passing an option which is not allowed' do
|
|
176
|
+
|
|
177
|
+
it 'should raise an error' do
|
|
178
|
+
expect(lambda {
|
|
179
|
+
client.send type, blog_name, :not => 'an option'
|
|
180
|
+
}).to raise_error ArgumentError
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
context 'when passing data as an array of filepaths' do
|
|
186
|
+
before do
|
|
187
|
+
fakefile = OpenStruct.new :read => file_data
|
|
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
|
+
'data[0]' => kind_of(Faraday::UploadIO),
|
|
191
|
+
:type => type.to_s
|
|
192
|
+
}).and_return('post')
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it 'should be able to pass data as an array of filepaths' do
|
|
196
|
+
r = client.send type, blog_name, :data => [file_path + ".jpg"]
|
|
197
|
+
expect(r).to eq('post')
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
it 'should be able to pass data as an array of uploadios' do
|
|
201
|
+
r = client.send type, blog_name, :data => [Faraday::UploadIO.new(StringIO.new, 'image/jpeg')]
|
|
202
|
+
expect(r).to eq('post')
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
context 'when passing data different ways' do
|
|
208
|
+
|
|
209
|
+
before do
|
|
210
|
+
fakefile = OpenStruct.new :read => file_data
|
|
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
|
+
'data' => kind_of(Faraday::UploadIO),
|
|
214
|
+
:type => type.to_s
|
|
215
|
+
}).and_return('post')
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it 'should be able to pass data as a single filepath' do
|
|
219
|
+
r = client.send type, blog_name, :data => file_path + ".jpg"
|
|
220
|
+
expect(r).to eq('post')
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
it 'should be able to pass data as a single uploadio' do
|
|
224
|
+
r = client.send type, blog_name, :data => Faraday::UploadIO.new(StringIO.new, 'image/jpeg')
|
|
225
|
+
expect(r).to eq('post')
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# Only photos have source
|
|
231
|
+
if type == :photo
|
|
232
|
+
|
|
233
|
+
context 'when passing source different ways' do
|
|
234
|
+
|
|
235
|
+
it 'should be able to be passed as a string' do
|
|
236
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post", {
|
|
237
|
+
:source => source,
|
|
238
|
+
:type => type.to_s
|
|
239
|
+
})
|
|
240
|
+
client.send type, blog_name, :source => source
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
it 'should be able to be passed as an array' do
|
|
244
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post", {
|
|
245
|
+
'source[0]' => source,
|
|
246
|
+
'source[1]' => source,
|
|
247
|
+
:type => type.to_s
|
|
248
|
+
})
|
|
249
|
+
client.send type, blog_name, :source => [source, source]
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
it 'should be able to be passed as an array on edit' do
|
|
253
|
+
expect(client).to receive(:post).once.with("v2/blog/#{blog_name}/post/edit", {
|
|
254
|
+
:id => post_id,
|
|
255
|
+
'source[0]' => source,
|
|
256
|
+
'source[1]' => source
|
|
257
|
+
})
|
|
258
|
+
client.edit blog_name, :id => post_id, :source => [source, source]
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
context 'when passing colliding options' do
|
|
266
|
+
|
|
267
|
+
it 'should get an error when passing data & source' do
|
|
268
|
+
expect(lambda {
|
|
269
|
+
client.send type, blog_name, :data => 'hi', :source => 'bye'
|
|
270
|
+
}).to raise_error ArgumentError
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
end
|