tumblr-rb 1.3.0 → 2.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +7 -0
- data/Gemfile +15 -8
- data/Gemfile.lock +65 -65
- data/LICENSE +4 -2
- data/README.md +31 -84
- data/Rakefile +8 -68
- data/bin/tumblr +3 -133
- data/lib/tumblr.rb +7 -184
- data/lib/tumblr/authentication.rb +71 -0
- data/lib/tumblr/client.rb +148 -0
- data/lib/tumblr/command_line_interface.rb +222 -0
- data/lib/tumblr/credentials.rb +31 -0
- data/lib/tumblr/post.rb +253 -171
- data/lib/tumblr/post/answer.rb +17 -0
- data/lib/tumblr/post/audio.rb +22 -10
- data/lib/tumblr/post/chat.rb +25 -0
- data/lib/tumblr/post/link.rb +22 -9
- data/lib/tumblr/post/photo.rb +29 -10
- data/lib/tumblr/post/quote.rb +17 -10
- data/lib/tumblr/post/text.rb +18 -0
- data/lib/tumblr/post/video.rb +26 -11
- data/lib/tumblr/version.rb +3 -0
- data/lib/tumblr/views/error.erb +6 -0
- data/lib/tumblr/views/form.erb +11 -0
- data/lib/tumblr/views/layout.erb +41 -0
- data/lib/tumblr/views/success.erb +6 -0
- data/man/tumblr.1 +67 -65
- data/man/tumblr.1.html +131 -108
- data/man/tumblr.1.ronn +76 -57
- data/man/tumblr.5 +48 -68
- data/man/tumblr.5.html +106 -114
- data/man/tumblr.5.ronn +38 -51
- data/spec/fixtures/posts.json +10 -0
- data/spec/fixtures/typical_animated_gif.gif +0 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/tumblr/authentication_spec.rb +57 -0
- data/spec/tumblr/client_spec.rb +223 -0
- data/spec/tumblr/credentials_spec.rb +63 -0
- data/spec/tumblr/post_spec.rb +125 -0
- data/tumblr-rb.gemspec +16 -89
- metadata +101 -102
- data/lib/tumblr/authenticator.rb +0 -18
- data/lib/tumblr/post/conversation.rb +0 -15
- data/lib/tumblr/post/regular.rb +0 -14
- data/lib/tumblr/reader.rb +0 -191
- data/lib/tumblr/writer.rb +0 -39
- data/test/fixtures/vcr_cassettes/authenticate/authenticate.yml +0 -39
- data/test/fixtures/vcr_cassettes/read/all_pages.yml +0 -34
- data/test/fixtures/vcr_cassettes/read/authenticated.yml +0 -40
- data/test/fixtures/vcr_cassettes/read/authentication_failure.yml +0 -33
- data/test/fixtures/vcr_cassettes/read/like.yml +0 -31
- data/test/fixtures/vcr_cassettes/read/mwunsch.yml +0 -101
- data/test/fixtures/vcr_cassettes/read/optional.yml +0 -48
- data/test/fixtures/vcr_cassettes/read/pages.yml +0 -36
- data/test/fixtures/vcr_cassettes/read/tumblrgemtest.yml +0 -42
- data/test/fixtures/vcr_cassettes/read/unlike.yml +0 -31
- data/test/fixtures/vcr_cassettes/write/delete.yml +0 -31
- data/test/fixtures/vcr_cassettes/write/edit.yml +0 -31
- data/test/fixtures/vcr_cassettes/write/reblog.yml +0 -31
- data/test/fixtures/vcr_cassettes/write/write.yml +0 -31
- data/test/helper.rb +0 -44
- data/test/test_tumblr.rb +0 -710
@@ -1,31 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::RecordedResponse
|
3
|
-
method: :post
|
4
|
-
uri: http://www.tumblr.com:80/api/unlike
|
5
|
-
response: !ruby/object:Net::HTTPOK
|
6
|
-
body: Unliked post 445597771.
|
7
|
-
body_exist: true
|
8
|
-
code: "200"
|
9
|
-
header:
|
10
|
-
p3p:
|
11
|
-
- CP="ALL ADM DEV PSAi COM OUR OTRo STP IND ONL"
|
12
|
-
content-type:
|
13
|
-
- text/plain; charset=utf-8
|
14
|
-
connection:
|
15
|
-
- close
|
16
|
-
x-tumblr-usec:
|
17
|
-
- D=119300
|
18
|
-
server:
|
19
|
-
- Apache/2.2.3 (Red Hat)
|
20
|
-
date:
|
21
|
-
- Sat, 13 Mar 2010 16:33:13 GMT
|
22
|
-
content-length:
|
23
|
-
- "23"
|
24
|
-
x-tumblr-perf:
|
25
|
-
- "\"ch:0/ cm:0/ ce:0/ c:0/0 d:0/0 e:0/0\""
|
26
|
-
vary:
|
27
|
-
- Accept-Encoding
|
28
|
-
http_version: "1.1"
|
29
|
-
message: OK
|
30
|
-
read: true
|
31
|
-
socket:
|
@@ -1,31 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::RecordedResponse
|
3
|
-
method: :post
|
4
|
-
uri: http://www.tumblr.com:80/api/delete
|
5
|
-
response: !ruby/object:Net::HTTPOK
|
6
|
-
body: Deleted
|
7
|
-
body_exist: true
|
8
|
-
code: "200"
|
9
|
-
header:
|
10
|
-
p3p:
|
11
|
-
- CP="ALL ADM DEV PSAi COM OUR OTRo STP IND ONL"
|
12
|
-
content-type:
|
13
|
-
- text/plain; charset=utf-8
|
14
|
-
connection:
|
15
|
-
- close
|
16
|
-
x-tumblr-usec:
|
17
|
-
- D=109741
|
18
|
-
server:
|
19
|
-
- Apache/2.2.3 (Red Hat)
|
20
|
-
date:
|
21
|
-
- Sun, 07 Mar 2010 07:09:10 GMT
|
22
|
-
content-length:
|
23
|
-
- "7"
|
24
|
-
x-tumblr-perf:
|
25
|
-
- "\"ch:7/country_code_for_ip,rate-limiter,posts,tumblelogs,version,users,users cm:2/rate-limiter,rate-limiter ce:0/ c:0/0 d:0/0 e:0/0\""
|
26
|
-
vary:
|
27
|
-
- Accept-Encoding
|
28
|
-
http_version: "1.1"
|
29
|
-
message: OK
|
30
|
-
read: true
|
31
|
-
socket:
|
@@ -1,31 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::RecordedResponse
|
3
|
-
method: :post
|
4
|
-
uri: http://www.tumblr.com:80/api/write
|
5
|
-
response: !ruby/object:Net::HTTPCreated
|
6
|
-
body: "431830023"
|
7
|
-
body_exist: true
|
8
|
-
code: "201"
|
9
|
-
header:
|
10
|
-
p3p:
|
11
|
-
- CP="ALL ADM DEV PSAi COM OUR OTRo STP IND ONL"
|
12
|
-
content-type:
|
13
|
-
- text/plain; charset=utf-8
|
14
|
-
connection:
|
15
|
-
- close
|
16
|
-
x-tumblr-usec:
|
17
|
-
- D=128043
|
18
|
-
server:
|
19
|
-
- Apache/2.2.3 (CentOS)
|
20
|
-
date:
|
21
|
-
- Sun, 07 Mar 2010 07:01:22 GMT
|
22
|
-
content-length:
|
23
|
-
- "9"
|
24
|
-
x-tumblr-perf:
|
25
|
-
- "\"ch:7/country_code_for_ip,rate-limiter,posts,tumblelogs,version,users,users cm:2/rate-limiter,rate-limiter ce:0/ c:0/0 d:0/0 e:0/0\""
|
26
|
-
vary:
|
27
|
-
- Accept-Encoding
|
28
|
-
http_version: "1.1"
|
29
|
-
message: Created
|
30
|
-
read: true
|
31
|
-
socket:
|
@@ -1,31 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::RecordedResponse
|
3
|
-
method: :post
|
4
|
-
uri: http://www.tumblr.com:80/api/reblog
|
5
|
-
response: !ruby/object:Net::HTTPCreated
|
6
|
-
body: "508128650"
|
7
|
-
body_exist: true
|
8
|
-
code: "201"
|
9
|
-
header:
|
10
|
-
p3p:
|
11
|
-
- CP="ALL ADM DEV PSAi COM OUR OTRo STP IND ONL"
|
12
|
-
content-type:
|
13
|
-
- text/plain; charset=utf-8
|
14
|
-
connection:
|
15
|
-
- close
|
16
|
-
x-tumblr-usec:
|
17
|
-
- D=380408
|
18
|
-
server:
|
19
|
-
- Apache/2.2.3 (Red Hat)
|
20
|
-
date:
|
21
|
-
- Fri, 09 Apr 2010 12:36:41 GMT
|
22
|
-
content-length:
|
23
|
-
- "9"
|
24
|
-
x-tumblr-perf:
|
25
|
-
- "\"ch:12/country_code_for_ip,posts,tumblelogs,tumblelogs,version,users,users,tumblelogs,tumblelogs,version,users,users cm:4/rate-limiter,rate-limiter,users,version ce:0/ c:0/0 d:0/0 e:0/0\""
|
26
|
-
vary:
|
27
|
-
- Accept-Encoding
|
28
|
-
http_version: "1.1"
|
29
|
-
message: Created
|
30
|
-
read: true
|
31
|
-
socket:
|
@@ -1,31 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::RecordedResponse
|
3
|
-
method: :post
|
4
|
-
uri: http://www.tumblr.com:80/api/write
|
5
|
-
response: !ruby/object:Net::HTTPCreated
|
6
|
-
body: "431830023"
|
7
|
-
body_exist: true
|
8
|
-
code: "201"
|
9
|
-
header:
|
10
|
-
p3p:
|
11
|
-
- CP="ALL ADM DEV PSAi COM OUR OTRo STP IND ONL"
|
12
|
-
content-type:
|
13
|
-
- text/plain; charset=utf-8
|
14
|
-
connection:
|
15
|
-
- close
|
16
|
-
x-tumblr-usec:
|
17
|
-
- D=137805
|
18
|
-
server:
|
19
|
-
- Apache/2.2.3 (Red Hat)
|
20
|
-
date:
|
21
|
-
- Sun, 07 Mar 2010 06:20:29 GMT
|
22
|
-
content-length:
|
23
|
-
- "9"
|
24
|
-
x-tumblr-perf:
|
25
|
-
- "\"ch:8/country_code_for_ip,rate-limiter,tumblelog_id_for_host,tumblelogs,users,version,users,users cm:2/rate-limiter,rate-limiter ce:0/ c:0/0 d:0/0 e:0/0\""
|
26
|
-
vary:
|
27
|
-
- Accept-Encoding
|
28
|
-
http_version: "1.1"
|
29
|
-
message: Created
|
30
|
-
read: true
|
31
|
-
socket:
|
data/test/helper.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
# Try to require the preresolved locked set of gems.
|
3
|
-
require File.expand_path('../.bundle/environment', __FILE__)
|
4
|
-
rescue LoadError
|
5
|
-
# Fall back on doing an unlocked resolve at runtime.
|
6
|
-
require "rubygems"
|
7
|
-
require "bundler"
|
8
|
-
Bundler.setup
|
9
|
-
end
|
10
|
-
|
11
|
-
require 'pp'
|
12
|
-
require 'test/unit'
|
13
|
-
require 'contest'
|
14
|
-
require 'vcr'
|
15
|
-
# Ruby 1.9 does not like redgreen
|
16
|
-
begin
|
17
|
-
require 'redgreen'
|
18
|
-
rescue LoadError
|
19
|
-
end
|
20
|
-
|
21
|
-
begin
|
22
|
-
require 'tumblr'
|
23
|
-
rescue LoadError
|
24
|
-
lib_path = File.join(File.dirname(__FILE__), '..', 'lib')
|
25
|
-
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
|
26
|
-
require 'tumblr'
|
27
|
-
end
|
28
|
-
|
29
|
-
FakeWeb.allow_net_connect = false
|
30
|
-
|
31
|
-
VCR.config do |c|
|
32
|
-
# the cache_dir is where the cassette yml files will be saved.
|
33
|
-
c.cassette_library_dir = File.join(File.dirname(__FILE__),'fixtures', 'vcr_cassettes')
|
34
|
-
|
35
|
-
# this record mode will be used for any cassette you create without specifying a record mode.
|
36
|
-
c.default_cassette_options = {:record => :none}
|
37
|
-
end
|
38
|
-
|
39
|
-
def hijack!(request, fixture)
|
40
|
-
record_mode = File.exist?(VCR::Cassette.new(fixture).file) ? :none : :unregistered
|
41
|
-
VCR.use_cassette(fixture, :record => record_mode) do
|
42
|
-
request.perform
|
43
|
-
end
|
44
|
-
end
|
data/test/test_tumblr.rb
DELETED
@@ -1,710 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestTumblr < Test::Unit::TestCase
|
4
|
-
describe 'Tumblr' do
|
5
|
-
test 'maps post types to the right class' do
|
6
|
-
assert_respond_to Tumblr, :map
|
7
|
-
assert_equal Tumblr::Post::Photo, Tumblr.map(:photo)
|
8
|
-
assert_raise RuntimeError do
|
9
|
-
Tumblr.map(:foobar)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'parses a post out of a document' do
|
14
|
-
klass = Class.new Tumblr::Post
|
15
|
-
klass.parameters :title, :body
|
16
|
-
type = :regular
|
17
|
-
post = klass.new
|
18
|
-
post.instance_variable_set(:@type,type)
|
19
|
-
post.body = "Hello world."
|
20
|
-
post.title = "Regular post"
|
21
|
-
document = post.to_s
|
22
|
-
assert Tumblr.parse(document).is_a? Tumblr.map(type)
|
23
|
-
assert_equal post.body, Tumblr.parse(document).body
|
24
|
-
assert_equal post.to_h, Tumblr.parse(document).to_h
|
25
|
-
assert_equal post.title, Tumblr.parse(document).title
|
26
|
-
end
|
27
|
-
|
28
|
-
test 'parses a document and sets up basic post' do
|
29
|
-
klass = Class.new Tumblr::Post
|
30
|
-
klass.parameters :title, :body
|
31
|
-
type = :regular
|
32
|
-
post = klass.new('123')
|
33
|
-
post.instance_variable_set(:@type,type)
|
34
|
-
post.tags 'hello', 'stuff'
|
35
|
-
post.state = :queue
|
36
|
-
post.format = :markdown
|
37
|
-
post.send_to_twitter 'Hi from tumblr'
|
38
|
-
post.publish_on 'tuesday'
|
39
|
-
post.date = Time.now.iso8601
|
40
|
-
post.body = "Hello world."
|
41
|
-
post.generator = Tumblr::GENERATOR
|
42
|
-
post.private = true
|
43
|
-
post.group = 'tumblrgemtest.tumblr.com'
|
44
|
-
document = post.to_s
|
45
|
-
|
46
|
-
%w(post_id format state tags send_to_twitter publish_on date generator private? group).each do |attribute|
|
47
|
-
assert_equal post.send(attribute), Tumblr.parse(document).send(attribute)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
test 'infers a post type from a document if none is explicitly set' do
|
52
|
-
link = 'http://something.com'
|
53
|
-
video = 'http://www.youtube.com/watch?v=CW0DUg63lqU'
|
54
|
-
text = "Hello world"
|
55
|
-
assert_equal :video, Tumblr.infer_post_type(video)
|
56
|
-
assert_equal :link, Tumblr.infer_post_type(link)
|
57
|
-
assert_equal :regular, Tumblr.infer_post_type(text)
|
58
|
-
end
|
59
|
-
|
60
|
-
test 'parses a document' do
|
61
|
-
link = <<-link
|
62
|
-
---
|
63
|
-
name: The Something Website
|
64
|
-
---
|
65
|
-
http://something.com
|
66
|
-
link
|
67
|
-
|
68
|
-
post = Tumblr.parse(link)
|
69
|
-
assert_equal :link, post.type
|
70
|
-
assert_equal 'The Something Website', post.name
|
71
|
-
assert_equal 'http://something.com', post.url
|
72
|
-
end
|
73
|
-
|
74
|
-
test 'sets up credentials for authentication' do
|
75
|
-
params = {:email => 'test@testermcgee.com', :password => 'dontrevealmysecrets'}
|
76
|
-
credentials = Tumblr.new(params[:email],params[:password]).instance_variable_get(:@credentials)
|
77
|
-
assert credentials.has_key? :email
|
78
|
-
assert credentials.has_key? :password
|
79
|
-
assert_equal params, credentials
|
80
|
-
end
|
81
|
-
|
82
|
-
test 'can read posts' do
|
83
|
-
assert Tumblr.new.read('mwunsch').is_a? Weary::Request
|
84
|
-
end
|
85
|
-
|
86
|
-
test 'can publish posts to tumblr' do
|
87
|
-
tumbl = Tumblr.new('test@testermcgee.com','dontrevealmysecrets')
|
88
|
-
write = tumbl.post('Hello world')
|
89
|
-
assert write.is_a? Weary::Request
|
90
|
-
end
|
91
|
-
|
92
|
-
test 'can read the dashboard' do
|
93
|
-
dashboard = Tumblr.new('test@testermcgee.com','dontrevealmysecrets').dashboard
|
94
|
-
reader = Tumblr::Reader.new('test@testermcgee.com','dontrevealmysecrets').dashboard
|
95
|
-
assert dashboard.is_a? Weary::Request
|
96
|
-
assert_equal reader.uri, dashboard.uri
|
97
|
-
end
|
98
|
-
|
99
|
-
test 'provides a convenience method for reader and writer' do
|
100
|
-
tumbl = Tumblr.new('test@testermcgee.com','dontrevealmysecrets')
|
101
|
-
assert tumbl.reader.is_a? Tumblr::Reader
|
102
|
-
assert tumbl.writer.is_a? Tumblr::Writer
|
103
|
-
end
|
104
|
-
|
105
|
-
test 'authenticates to get user information' do
|
106
|
-
tumbl = Tumblr.new('test@testermcgee.com','dontrevealmysecrets')
|
107
|
-
auth = Tumblr::Authenticator.new('test@testermcgee.com','dontrevealmysecrets').authenticate
|
108
|
-
assert_respond_to tumbl, :authenticate
|
109
|
-
assert tumbl.authenticate.is_a? Weary::Request
|
110
|
-
assert_equal auth.uri, tumbl.authenticate.uri
|
111
|
-
end
|
112
|
-
|
113
|
-
test 'can pass include theme params to authenticate method' do
|
114
|
-
tumbl = Tumblr.new('test@testermcgee.com','dontrevealmysecrets')
|
115
|
-
include_theme = tumbl.authenticate(true)
|
116
|
-
assert include_theme.with.split('&').include?("include-theme=1")
|
117
|
-
end
|
118
|
-
|
119
|
-
test 'executes' do
|
120
|
-
cred = {:email => 'test@testermcgee.com', :password => 'dontrevealmysecrets'}
|
121
|
-
response = VCR.use_cassette('write/write') do
|
122
|
-
Tumblr.execute(cred, 'Hello World.')
|
123
|
-
end
|
124
|
-
assert response.is_a? Weary::Response
|
125
|
-
assert response.success?
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe 'Reader' do
|
130
|
-
test 'sets up credentials for authentication' do
|
131
|
-
reader = Tumblr::Reader
|
132
|
-
assert !reader.new.defaults
|
133
|
-
params = {:email => 'test@testermcgee.com', :password => 'dontrevealmysecrets'}
|
134
|
-
credentials = reader.new(params[:email],params[:password]).defaults
|
135
|
-
assert credentials.has_key? :email
|
136
|
-
assert credentials.has_key? :password
|
137
|
-
assert_equal params, credentials
|
138
|
-
end
|
139
|
-
|
140
|
-
test 'handles parameters for reads' do
|
141
|
-
reader = Tumblr::Reader
|
142
|
-
options = {:start => 5, :num => 10, :foo => 'Bar', :type => 'video'}
|
143
|
-
cred = {:email => 'test@testermcgee.com', :password => 'dontrevealmysecrets'}
|
144
|
-
assert !reader.new.parameters(options).has_key?(:foo)
|
145
|
-
assert_equal cred[:email], reader.new(cred[:email],cred[:password]).parameters(options)[:email]
|
146
|
-
assert reader.new(*cred.values).parameters(options).has_key?(:password)
|
147
|
-
end
|
148
|
-
|
149
|
-
test 'convenience method for reads' do
|
150
|
-
t = Tumblr::Reader
|
151
|
-
assert_respond_to t, :read
|
152
|
-
assert_equal :get, t.read('mwunsch').via
|
153
|
-
assert_equal 'http://mwunsch.tumblr.com/api/read/', t.read('mwunsch').uri.normalize.to_s
|
154
|
-
assert_equal :post, t.read('mwunsch',:post).via
|
155
|
-
params = {:email => 'test@testermcgee.com', :password => 'dontrevealmysecrets'}
|
156
|
-
assert_equal params.to_params, t.read('mwunsch',:post,params).with
|
157
|
-
end
|
158
|
-
|
159
|
-
test 'reads posts' do
|
160
|
-
reader = Tumblr::Reader
|
161
|
-
mwunsch = reader.new.read('mwunsch')
|
162
|
-
assert_respond_to mwunsch, :perform
|
163
|
-
assert_equal 'http://mwunsch.tumblr.com/api/read/', mwunsch.uri.normalize.to_s
|
164
|
-
response = hijack! mwunsch, 'read/mwunsch'
|
165
|
-
assert response.success?
|
166
|
-
assert_equal :xml, response.format
|
167
|
-
end
|
168
|
-
|
169
|
-
test 'reads posts with some optional parameters' do
|
170
|
-
reader = Tumblr::Reader
|
171
|
-
options = {:num => 5, :type => :video}
|
172
|
-
posts = reader.new.read 'mwunsch', options
|
173
|
-
response = hijack! posts, 'read/optional'
|
174
|
-
parsed = response.parse["tumblr"]["posts"]
|
175
|
-
assert_equal "video", parsed["type"]
|
176
|
-
assert_equal 5, parsed['post'].count
|
177
|
-
end
|
178
|
-
|
179
|
-
test 'attempts to perform an authenticated read' do
|
180
|
-
reader = Tumblr::Reader
|
181
|
-
auth = reader.new('test@testermcgee.com','dontrevealmysecrets').authenticated_read('mwunsch',{:state => :draft})
|
182
|
-
response = hijack! auth, 'read/authenticated'
|
183
|
-
assert_equal '420292045', response['tumblr']['posts']['post']['id']
|
184
|
-
end
|
185
|
-
|
186
|
-
test 'sometimes authentication fails' do
|
187
|
-
reader = Tumblr::Reader
|
188
|
-
auth = reader.new('test@testermcgee.com','dontrevealmysecrets').authenticated_read('mwunsch')
|
189
|
-
response = hijack! auth, 'read/authentication failure'
|
190
|
-
assert !response.success?
|
191
|
-
assert_equal 403, response.code
|
192
|
-
end
|
193
|
-
|
194
|
-
test 'can not do an authenticated read without credentials' do
|
195
|
-
reader = Tumblr::Reader
|
196
|
-
assert_raise RuntimeError do
|
197
|
-
reader.new.authenticated_read('mwunsch')
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
# need to test these more thoroughly
|
202
|
-
test 'has several other authenticated read methods' do
|
203
|
-
reader = Tumblr::Reader.new
|
204
|
-
assert_respond_to reader, :dashboard
|
205
|
-
assert_respond_to reader, :likes
|
206
|
-
assert_respond_to reader, :like
|
207
|
-
assert_respond_to reader, :unlike
|
208
|
-
end
|
209
|
-
|
210
|
-
test 'likes a post' do
|
211
|
-
reader = Tumblr::Reader.new('test@testermcgee.com','dontrevealmysecrets')
|
212
|
-
like = hijack! reader.like(:'post-id' => '445597771', :'reblog-key' => 'DLVWOpfh'), 'read/like'
|
213
|
-
assert like.success?
|
214
|
-
end
|
215
|
-
|
216
|
-
test 'unlikes a post' do
|
217
|
-
reader = Tumblr::Reader.new('test@testermcgee.com','dontrevealmysecrets')
|
218
|
-
unlike = hijack! reader.unlike(:'post-id' => '445597771', :'reblog-key' => 'DLVWOpfh'), 'read/unlike'
|
219
|
-
assert unlike.success?
|
220
|
-
end
|
221
|
-
|
222
|
-
test 'parses posts out of a read' do
|
223
|
-
reader = Tumblr::Reader
|
224
|
-
assert_respond_to reader, :get_posts
|
225
|
-
mwunsch = reader.new.read('mwunsch')
|
226
|
-
response = hijack! mwunsch, 'read/mwunsch'
|
227
|
-
assert_equal response['tumblr']['posts']['post'].count, reader.get_posts(response).count
|
228
|
-
assert reader.get_posts(response).first.is_a? Tumblr::Post::Quote
|
229
|
-
end
|
230
|
-
|
231
|
-
test 'selects posts by type' do
|
232
|
-
reader = Tumblr::Reader
|
233
|
-
assert_respond_to reader, :get_posts
|
234
|
-
mwunsch = reader.new.read('mwunsch')
|
235
|
-
response = hijack! mwunsch, 'read/mwunsch'
|
236
|
-
assert reader.get_posts(response, :link).first.is_a? Tumblr::Post::Link
|
237
|
-
end
|
238
|
-
|
239
|
-
test 'generates a Post object from a parsed post' do
|
240
|
-
reader = Tumblr::Reader
|
241
|
-
assert_respond_to reader, :build_post
|
242
|
-
mwunsch = reader.new.read('mwunsch')
|
243
|
-
response = hijack! mwunsch, 'read/mwunsch'
|
244
|
-
posts = response['tumblr']['posts']['post']
|
245
|
-
link = posts.select {|post| post['type'].eql?('link') }
|
246
|
-
link_post = reader.build_post(link.first)
|
247
|
-
assert link_post.is_a? Tumblr::Post::Link
|
248
|
-
assert_equal :link, link_post.type
|
249
|
-
assert_equal :markdown, link_post.format
|
250
|
-
assert_equal link.first['link_url'], link_post.url
|
251
|
-
assert_equal link.first['reblog_key'], link_post.reblog_key
|
252
|
-
end
|
253
|
-
|
254
|
-
test 'gets all the posts for a username' do
|
255
|
-
reader = Tumblr::Reader.new('test@testermcgee.com','dontrevealmysecrets')
|
256
|
-
posts = VCR.use_cassette('read/authenticated') do
|
257
|
-
reader.get_all_posts('mwunsch')
|
258
|
-
end
|
259
|
-
assert_equal 66, posts.count
|
260
|
-
end
|
261
|
-
|
262
|
-
test 'read pages' do
|
263
|
-
reader = Tumblr::Reader.new
|
264
|
-
assert_respond_to reader, :pages
|
265
|
-
response = hijack! reader.pages('tumblrgemtest'), 'read/pages'
|
266
|
-
assert response['tumblr'].has_key?("pages")
|
267
|
-
end
|
268
|
-
|
269
|
-
test 'reads all pages by authenticating' do
|
270
|
-
reader = Tumblr::Reader.new('test@testermcgee.com','dontrevealmysecrets')
|
271
|
-
assert_respond_to reader, :all_pages
|
272
|
-
response = hijack! reader.all_pages('tumblrgemtest'), 'read/all_pages'
|
273
|
-
assert_equal 200, response.code
|
274
|
-
assert_equal 2, response['tumblr']['pages']['page'].count
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
describe 'Writer' do
|
279
|
-
test 'sets up credentials for authentication' do
|
280
|
-
writer = Tumblr::Writer
|
281
|
-
params = {:email => 'test@testermcgee.com', :password => 'dontrevealmysecrets'}
|
282
|
-
credentials = writer.new(params[:email],params[:password]).defaults
|
283
|
-
assert credentials.has_key? :email
|
284
|
-
assert credentials.has_key? :password
|
285
|
-
end
|
286
|
-
|
287
|
-
test 'writes a post' do
|
288
|
-
writer = Tumblr::Writer
|
289
|
-
assert_respond_to writer.new, :write
|
290
|
-
post = {:type => :regular, :body => 'Hello world.', :group => 'tumblrgemtest.tumblr.com'}
|
291
|
-
publisher = Tumblr::Writer.new('test@testermcgee.com','dontrevealmysecrets')
|
292
|
-
response = hijack! publisher.write(post), 'write/write'
|
293
|
-
assert_equal 201, response.code
|
294
|
-
end
|
295
|
-
|
296
|
-
test 'edits an existing post' do
|
297
|
-
assert_respond_to Tumblr::Writer.new, :edit
|
298
|
-
publisher = Tumblr::Writer.new('test@testermcgee.com','dontrevealmysecrets')
|
299
|
-
post = {:'post-id' => "431830023", :body => 'Hello world?'}
|
300
|
-
response = hijack! publisher.edit(post), 'write/edit'
|
301
|
-
assert_equal 201, response.code
|
302
|
-
end
|
303
|
-
|
304
|
-
test 'deletes a post' do
|
305
|
-
assert_respond_to Tumblr::Writer.new, :edit
|
306
|
-
publisher = Tumblr::Writer.new('test@testermcgee.com','dontrevealmysecrets')
|
307
|
-
post = {:'post-id' => "431830023"}
|
308
|
-
response = hijack! publisher.delete(post), 'write/delete'
|
309
|
-
assert response.success?
|
310
|
-
assert_equal 'Deleted', response.body
|
311
|
-
end
|
312
|
-
|
313
|
-
test 'reblogs a post' do
|
314
|
-
assert_respond_to Tumblr::Writer.new, :reblog
|
315
|
-
publisher = Tumblr::Writer.new('test@testermcgee.com','dontrevealmysecrets')
|
316
|
-
post = {:'post-id' => "507998507", :'reblog-key' => 'DifhdmQI'}
|
317
|
-
response = hijack! publisher.reblog(post), 'write/reblog'
|
318
|
-
assert_equal 201, response.code
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
describe 'Authenticator' do
|
323
|
-
test 'sets up credentials for authentication' do
|
324
|
-
user = Tumblr::Authenticator
|
325
|
-
params = {:email => 'test@testermcgee.com', :password => 'dontrevealmysecrets'}
|
326
|
-
credentials = user.new(params[:email],params[:password]).defaults
|
327
|
-
assert credentials.has_key? :email
|
328
|
-
assert credentials.has_key? :password
|
329
|
-
end
|
330
|
-
|
331
|
-
test 'authenticates a user to get information' do
|
332
|
-
user = Tumblr::Authenticator.new('test@testermcgee.com','dontrevealmysecrets')
|
333
|
-
assert_respond_to user, :authenticate
|
334
|
-
response = hijack! user.authenticate, 'authenticate/authenticate'
|
335
|
-
assert response.success?
|
336
|
-
assert_equal 'mwunsch', response["tumblr"]["tumblelog"].first["name"]
|
337
|
-
end
|
338
|
-
|
339
|
-
test 'can include an optional theme' do
|
340
|
-
user = Tumblr::Authenticator.new('test@testermcgee.com','dontrevealmysecrets')
|
341
|
-
assert user.authenticate(:'include-theme' => 1).with.split('&').include?("include-theme=1")
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
describe 'Post' do
|
346
|
-
describe 'Basic' do
|
347
|
-
test 'has a set of post-specific parameters' do
|
348
|
-
klass = Class.new(Tumblr::Post)
|
349
|
-
assert_respond_to klass, :parameters
|
350
|
-
klass.parameters :title, :body
|
351
|
-
assert klass.parameters.include? :title
|
352
|
-
post = klass.new
|
353
|
-
assert_respond_to post, :title
|
354
|
-
post.title = 'Hello world'
|
355
|
-
assert_equal 'Hello world', post.title
|
356
|
-
end
|
357
|
-
|
358
|
-
test 'can have a post_id already set' do
|
359
|
-
post = Tumblr::Post.new
|
360
|
-
assert !post.post_id
|
361
|
-
post = Tumblr::Post.new 123
|
362
|
-
assert_equal 123, post.post_id
|
363
|
-
end
|
364
|
-
|
365
|
-
test 'sets a date for publishing in the past' do
|
366
|
-
post = Tumblr::Post.new
|
367
|
-
assert_respond_to post, :date
|
368
|
-
right_now = Time.now.iso8601
|
369
|
-
post.date = right_now
|
370
|
-
assert_equal right_now, post.date
|
371
|
-
end
|
372
|
-
|
373
|
-
test 'can be a private post' do
|
374
|
-
post = Tumblr::Post.new
|
375
|
-
assert_respond_to post, :private?
|
376
|
-
assert !post.private?
|
377
|
-
post.private = true
|
378
|
-
assert post.private?
|
379
|
-
end
|
380
|
-
|
381
|
-
test 'can have a reblog key' do
|
382
|
-
post = Tumblr::Post.new
|
383
|
-
assert_respond_to post, :reblog_key
|
384
|
-
post.reblog_key = 'reblog_me'
|
385
|
-
assert_equal 'reblog_me', post.reblog_key
|
386
|
-
end
|
387
|
-
|
388
|
-
test 'has a comma separated list of tags' do
|
389
|
-
post = Tumblr::Post.new
|
390
|
-
assert_respond_to post, :tags
|
391
|
-
post.tags :tumblr, :whatever, :ruby
|
392
|
-
assert_equal 'tumblr,whatever,ruby', post.tags
|
393
|
-
end
|
394
|
-
|
395
|
-
test 'can set its format to be html or markdown' do
|
396
|
-
post = Tumblr::Post.new
|
397
|
-
assert_respond_to post, :format
|
398
|
-
post.format = :foobar
|
399
|
-
assert !post.format
|
400
|
-
post.format = :markdown
|
401
|
-
assert_equal :markdown, post.format
|
402
|
-
end
|
403
|
-
|
404
|
-
test 'can set this post to be published to a secondary blog' do
|
405
|
-
post = Tumblr::Post.new
|
406
|
-
assert_respond_to post, :group
|
407
|
-
post.group = 'mygroup.tumblr.com'
|
408
|
-
assert_equal 'mygroup.tumblr.com', post.group
|
409
|
-
end
|
410
|
-
|
411
|
-
test 'sets a slug for its url' do
|
412
|
-
post = Tumblr::Post.new
|
413
|
-
assert_respond_to post, :slug
|
414
|
-
post.slug = "this-string-right-here"
|
415
|
-
assert_equal "this-string-right-here", post.slug
|
416
|
-
end
|
417
|
-
|
418
|
-
test 'can change published state' do
|
419
|
-
post = Tumblr::Post.new
|
420
|
-
assert_respond_to post, :state
|
421
|
-
post.state = 'queue'
|
422
|
-
assert_equal :queue, post.state
|
423
|
-
assert_raise RuntimeError do
|
424
|
-
post.state = 'foobar'
|
425
|
-
end
|
426
|
-
end
|
427
|
-
|
428
|
-
test 'sends to twitter' do
|
429
|
-
post = Tumblr::Post.new
|
430
|
-
assert_respond_to post, :send_to_twitter
|
431
|
-
assert !post.send_to_twitter
|
432
|
-
post.send_to_twitter :no
|
433
|
-
assert !post.send_to_twitter
|
434
|
-
post.send_to_twitter 'Updating twitter through tumblr'
|
435
|
-
assert_equal 'Updating twitter through tumblr', post.send_to_twitter
|
436
|
-
end
|
437
|
-
|
438
|
-
test 'if the published state is in the queue, specify a publish date' do
|
439
|
-
post = Tumblr::Post.new
|
440
|
-
assert_respond_to post, :publish_on
|
441
|
-
right_now = Time.now.iso8601
|
442
|
-
post.publish_on right_now
|
443
|
-
assert !post.publish_on
|
444
|
-
post.state = :queue
|
445
|
-
post.publish_on right_now
|
446
|
-
assert_equal right_now, post.publish_on
|
447
|
-
end
|
448
|
-
|
449
|
-
test 'converts to a hash' do
|
450
|
-
post = Tumblr::Post.new(123)
|
451
|
-
post.private = 1
|
452
|
-
assert_respond_to post, :to_h
|
453
|
-
assert_equal 1, post.to_h[:private]
|
454
|
-
assert_equal 123, post.to_h[:'post-id']
|
455
|
-
klass = Class.new(post.class)
|
456
|
-
klass.parameters :title, :body
|
457
|
-
new_post = klass.new(456)
|
458
|
-
new_post.title = "Hello world"
|
459
|
-
assert_equal 'Hello world', new_post.to_h[:title]
|
460
|
-
assert !new_post.to_h.has_key?(:body)
|
461
|
-
end
|
462
|
-
|
463
|
-
test 'writes itself to tumblr' do
|
464
|
-
klass = Class.new Tumblr::Post
|
465
|
-
post = klass.new
|
466
|
-
post.instance_variable_set(:@type,:regular)
|
467
|
-
assert post.write('test@testermcgee.com','dontrevealmysecrets').is_a? Weary::Request
|
468
|
-
end
|
469
|
-
|
470
|
-
test 'edits itself on tumblr' do
|
471
|
-
post = Tumblr::Post.new(123)
|
472
|
-
assert post.edit('test@testermcgee.com','dontrevealmysecrets').is_a? Weary::Request
|
473
|
-
end
|
474
|
-
|
475
|
-
test 'deletes itself' do
|
476
|
-
post = Tumblr::Post.new(123)
|
477
|
-
assert post.delete('test@testermcgee.com','dontrevealmysecrets').is_a? Weary::Request
|
478
|
-
end
|
479
|
-
|
480
|
-
test 'reblogs itself' do
|
481
|
-
post = Tumblr::Post.new(123)
|
482
|
-
post.reblog_key = '0U812'
|
483
|
-
assert post.reblog('test@testermcgee.com','dontrevealmysecrets').is_a? Weary::Request
|
484
|
-
end
|
485
|
-
|
486
|
-
test 'likes itself' do
|
487
|
-
post = Tumblr::Post.new(445597771)
|
488
|
-
post.reblog_key = "DLVWOpfh"
|
489
|
-
like = post.like('test@testermcgee.com','dontrevealmysecrets')
|
490
|
-
assert like.is_a? Weary::Request
|
491
|
-
assert_equal 'http://www.tumblr.com/api/like', like.uri.to_s
|
492
|
-
end
|
493
|
-
|
494
|
-
test 'unlikes itself' do
|
495
|
-
post = Tumblr::Post.new(445597771)
|
496
|
-
post.reblog_key = "DLVWOpfh"
|
497
|
-
unlike = post.unlike('test@testermcgee.com','dontrevealmysecrets')
|
498
|
-
assert unlike.is_a? Weary::Request
|
499
|
-
assert_equal 'http://www.tumblr.com/api/unlike', unlike.uri.to_s
|
500
|
-
end
|
501
|
-
|
502
|
-
test 'publishes to tumblr' do
|
503
|
-
klass = Class.new Tumblr::Post
|
504
|
-
post = klass.new
|
505
|
-
post.instance_variable_set(:@type,:regular)
|
506
|
-
post.state = :queue
|
507
|
-
assert post.publish_now('test@testermcgee.com','dontrevealmysecrets').is_a? Weary::Request
|
508
|
-
assert_equal :published, post.state
|
509
|
-
end
|
510
|
-
|
511
|
-
test 'saves as a draft to tumblr' do
|
512
|
-
klass = Class.new Tumblr::Post
|
513
|
-
post = klass.new
|
514
|
-
post.instance_variable_set(:@type,:regular)
|
515
|
-
post.state = :published
|
516
|
-
assert post.save_as_draft('test@testermcgee.com','dontrevealmysecrets').is_a? Weary::Request
|
517
|
-
assert_equal :draft, post.state
|
518
|
-
end
|
519
|
-
|
520
|
-
test 'adds to tumblr queue' do
|
521
|
-
klass = Class.new Tumblr::Post
|
522
|
-
post = klass.new
|
523
|
-
post.instance_variable_set(:@type,:regular)
|
524
|
-
post.state = :draft
|
525
|
-
assert post.add_to_queue('test@testermcgee.com','dontrevealmysecrets').is_a? Weary::Request
|
526
|
-
assert_equal :queue, post.state
|
527
|
-
end
|
528
|
-
|
529
|
-
test 'publish on a specific date' do
|
530
|
-
klass = Class.new Tumblr::Post
|
531
|
-
post = klass.new
|
532
|
-
post.instance_variable_set(:@type,:regular)
|
533
|
-
post.state = :draft
|
534
|
-
assert post.add_to_queue('test@testermcgee.com','dontrevealmysecrets','tuesday').is_a? Weary::Request
|
535
|
-
assert_equal :queue, post.state
|
536
|
-
assert_equal 'tuesday',post.publish_on
|
537
|
-
end
|
538
|
-
|
539
|
-
test 'converts itself to YAML' do
|
540
|
-
klass = Class.new Tumblr::Post
|
541
|
-
klass.parameters :title, :body
|
542
|
-
post = klass.new
|
543
|
-
post.instance_variable_set(:@type,:regular)
|
544
|
-
post.tags 'hello', 'stuff'
|
545
|
-
post.state = :queue
|
546
|
-
post.body = "Hello world."
|
547
|
-
assert_respond_to post, :to_yaml
|
548
|
-
post_yaml = post.to_yaml
|
549
|
-
assert_equal 'Hello world.', YAML.load(post_yaml)['body']
|
550
|
-
assert_equal 'regular', YAML.load(post_yaml)['data']['type']
|
551
|
-
end
|
552
|
-
|
553
|
-
test 'converts itself to a string for writing to a file' do
|
554
|
-
klass = Class.new Tumblr::Post
|
555
|
-
klass.parameters :title, :body
|
556
|
-
post = klass.new
|
557
|
-
post.instance_variable_set(:@type,:regular)
|
558
|
-
post.tags 'hello', 'stuff'
|
559
|
-
post.state = :queue
|
560
|
-
post.body = "Hello world."
|
561
|
-
assert_equal 'regular', YAML.load(post.to_s)['type']
|
562
|
-
end
|
563
|
-
end
|
564
|
-
|
565
|
-
describe 'Regular' do
|
566
|
-
test 'is of regular type' do
|
567
|
-
reg = Tumblr::Post::Regular.new
|
568
|
-
assert_equal :regular, reg.type
|
569
|
-
end
|
570
|
-
|
571
|
-
test 'has a body' do
|
572
|
-
reg = Tumblr::Post::Regular.new
|
573
|
-
assert_respond_to reg, :body
|
574
|
-
reg.body = "Hi"
|
575
|
-
assert_equal "Hi", reg.body
|
576
|
-
end
|
577
|
-
|
578
|
-
test 'has a title' do
|
579
|
-
reg = Tumblr::Post::Regular.new
|
580
|
-
assert_respond_to reg, :title
|
581
|
-
reg.title = "Hi"
|
582
|
-
assert_equal "Hi", reg.title
|
583
|
-
end
|
584
|
-
end
|
585
|
-
|
586
|
-
describe 'Photo' do
|
587
|
-
test 'is a photo' do
|
588
|
-
photo = Tumblr::Post::Photo.new
|
589
|
-
assert_equal :photo, photo.type
|
590
|
-
end
|
591
|
-
|
592
|
-
test 'has a source' do
|
593
|
-
photo = Tumblr::Post::Photo.new
|
594
|
-
photo.source = "http://foo.bar/picture.png"
|
595
|
-
assert_equal "http://foo.bar/picture.png", photo.source
|
596
|
-
end
|
597
|
-
|
598
|
-
test 'has a caption' do
|
599
|
-
photo = Tumblr::Post::Photo.new
|
600
|
-
photo.caption = "Me in my youth"
|
601
|
-
assert_equal "Me in my youth", photo.caption
|
602
|
-
end
|
603
|
-
|
604
|
-
test 'has a click-through-url' do
|
605
|
-
photo = Tumblr::Post::Photo.new
|
606
|
-
photo.click_through_url = "http://tumblr.com"
|
607
|
-
assert_equal "http://tumblr.com", photo.click_through_url
|
608
|
-
end
|
609
|
-
end
|
610
|
-
|
611
|
-
describe 'Quote' do
|
612
|
-
test 'is a quote' do
|
613
|
-
quote = Tumblr::Post::Quote.new("To be or not to be")
|
614
|
-
assert_equal :quote, quote.type
|
615
|
-
end
|
616
|
-
|
617
|
-
test 'the quote is text' do
|
618
|
-
quote = Tumblr::Post::Quote.new("To be or not to be")
|
619
|
-
assert_equal "To be or not to be", quote.quote
|
620
|
-
quote.quote = "that is the question."
|
621
|
-
assert_equal "that is the question.", quote.quote
|
622
|
-
end
|
623
|
-
|
624
|
-
test 'the quote has a source' do
|
625
|
-
quote = Tumblr::Post::Quote.new("To be or not to be")
|
626
|
-
quote.source = "Hamlet"
|
627
|
-
assert_equal 'Hamlet', quote.source
|
628
|
-
end
|
629
|
-
end
|
630
|
-
|
631
|
-
describe 'Link' do
|
632
|
-
test 'is a link' do
|
633
|
-
link = Tumblr::Post::Link.new('http://tumblr.com')
|
634
|
-
assert_equal :link, link.type
|
635
|
-
end
|
636
|
-
|
637
|
-
test 'is a link to something' do
|
638
|
-
link = Tumblr::Post::Link.new('http://tumblr.com')
|
639
|
-
assert_equal 'http://tumblr.com', link.url
|
640
|
-
end
|
641
|
-
|
642
|
-
test 'has an optional name' do
|
643
|
-
link = Tumblr::Post::Link.new('http://tumblr.com')
|
644
|
-
link.name = 'Tumblr'
|
645
|
-
assert_equal 'Tumblr', link.name
|
646
|
-
end
|
647
|
-
|
648
|
-
test 'has an optional description' do
|
649
|
-
link = Tumblr::Post::Link.new('http://tumblr.com')
|
650
|
-
link.description = "Simple blogging"
|
651
|
-
assert_equal 'Simple blogging', link.description
|
652
|
-
end
|
653
|
-
end
|
654
|
-
|
655
|
-
describe 'Conversation' do
|
656
|
-
test 'is a conversation' do
|
657
|
-
conversation = Tumblr::Post::Conversation.new('Me: hey whatsup')
|
658
|
-
assert_equal :conversation, conversation.type
|
659
|
-
end
|
660
|
-
|
661
|
-
test 'requires a chat' do
|
662
|
-
conversation = Tumblr::Post::Conversation.new('Me: hey whatsup')
|
663
|
-
assert_equal 'Me: hey whatsup', conversation.conversation
|
664
|
-
end
|
665
|
-
|
666
|
-
test 'has an optional title' do
|
667
|
-
conversation = Tumblr::Post::Conversation.new('Me: hey whatsup')
|
668
|
-
conversation.title = 'Inner dialogue'
|
669
|
-
assert_equal 'Inner dialogue', conversation.title
|
670
|
-
end
|
671
|
-
end
|
672
|
-
|
673
|
-
describe 'Video' do
|
674
|
-
test 'is a video' do
|
675
|
-
video = Tumblr::Post::Video.new('http://www.youtube.com/watch?v=CW0DUg63lqU')
|
676
|
-
assert_equal :video, video.type
|
677
|
-
end
|
678
|
-
|
679
|
-
test 'has a url or embed code' do
|
680
|
-
video = Tumblr::Post::Video.new('http://www.youtube.com/watch?v=CW0DUg63lqU')
|
681
|
-
assert_equal 'http://www.youtube.com/watch?v=CW0DUg63lqU', video.embed
|
682
|
-
end
|
683
|
-
|
684
|
-
test 'has a caption' do
|
685
|
-
video = Tumblr::Post::Video.new('http://www.youtube.com/watch?v=CW0DUg63lqU')
|
686
|
-
video.caption = 'Good artists copy...'
|
687
|
-
assert_equal 'Good artists copy...', video.caption
|
688
|
-
end
|
689
|
-
end
|
690
|
-
|
691
|
-
describe 'Audio' do
|
692
|
-
test 'is audio' do
|
693
|
-
audio = Tumblr::Post::Audio.new
|
694
|
-
assert_equal :audio, audio.type
|
695
|
-
end
|
696
|
-
|
697
|
-
test 'can be a hosted url to an mp3 file' do
|
698
|
-
audio = Tumblr::Post::Audio.new
|
699
|
-
audio.externally_hosted_url = 'http://foobar.com/some.mp3'
|
700
|
-
assert_equal 'http://foobar.com/some.mp3', audio.externally_hosted_url
|
701
|
-
end
|
702
|
-
|
703
|
-
test 'has an optional caption' do
|
704
|
-
audio = Tumblr::Post::Audio.new
|
705
|
-
audio.caption = 'not pirated'
|
706
|
-
assert_equal 'not pirated', audio.caption
|
707
|
-
end
|
708
|
-
end
|
709
|
-
end
|
710
|
-
end
|