test/test_tumblr.rb in tumblr-rb-1.0.0 vs test/test_tumblr.rb in tumblr-rb-1.1.0
- old
+ new
@@ -198,10 +198,22 @@
assert_respond_to reader, :dashboard
assert_respond_to reader, :likes
assert_respond_to reader, :like
assert_respond_to reader, :unlike
end
+
+ test 'likes a post' do
+ reader = Tumblr::Reader.new('test@testermcgee.com','dontrevealmysecrets')
+ like = hijack! reader.like(:'post-id' => '445597771', :'reblog-key' => 'DLVWOpfh'), 'read/like'
+ assert like.success?
+ end
+
+ test 'unlikes a post' do
+ reader = Tumblr::Reader.new('test@testermcgee.com','dontrevealmysecrets')
+ unlike = hijack! reader.unlike(:'post-id' => '445597771', :'reblog-key' => 'DLVWOpfh'), 'read/unlike'
+ assert unlike.success?
+ end
test 'parses posts out of a read' do
reader = Tumblr::Reader
assert_respond_to reader, :get_posts
mwunsch = reader.new.read('mwunsch')
@@ -228,11 +240,20 @@
link_post = reader.build_post(link.first)
assert link_post.is_a? Tumblr::Post::Link
assert_equal :link, link_post.type
assert_equal :markdown, link_post.format
assert_equal link.first['link_url'], link_post.url
+ assert_equal link.first['reblog_key'], link_post.reblog_key
end
+
+ test 'gets all the posts for a username' do
+ reader = Tumblr::Reader.new('test@testermcgee.com','dontrevealmysecrets')
+ posts = VCR.with_cassette('read/authenticated') do
+ reader.get_all_posts('mwunsch')
+ end
+ assert_equal 66, posts.count
+ end
end
describe 'Writer' do
test 'sets up credentials for authentication' do
writer = Tumblr::Writer
@@ -285,11 +306,11 @@
assert response.success?
assert_equal 'mwunsch', response["tumblr"]["tumblelog"].first["name"]
end
end
- describe 'Post' do
+ describe 'Post' do
describe 'Basic' do
test 'has a set of post-specific parameters' do
klass = Class.new(Tumblr::Post)
assert_respond_to klass, :parameters
klass.parameters :title, :body
@@ -321,10 +342,17 @@
assert !post.private?
post.private = true
assert post.private?
end
+ test 'can have a reblog key' do
+ post = Tumblr::Post.new
+ assert_respond_to post, :reblog_key
+ post.reblog_key = 'reblog_me'
+ assert_equal 'reblog_me', post.reblog_key
+ end
+
test 'has a comma separated list of tags' do
post = Tumblr::Post.new
assert_respond_to post, :tags
post.tags :tumblr, :whatever, :ruby
assert_equal 'tumblr,whatever,ruby', post.tags
@@ -411,9 +439,25 @@
end
test 'deletes itself' do
post = Tumblr::Post.new(123)
assert post.delete('test@testermcgee.com','dontrevealmysecrets').is_a? Weary::Request
+ end
+
+ test 'likes itself' do
+ post = Tumblr::Post.new(445597771)
+ post.reblog_key = "DLVWOpfh"
+ like = post.like('test@testermcgee.com','dontrevealmysecrets')
+ assert like.is_a? Weary::Request
+ assert_equal 'http://www.tumblr.com/api/like', like.uri.to_s
+ end
+
+ test 'unlikes itself' do
+ post = Tumblr::Post.new(445597771)
+ post.reblog_key = "DLVWOpfh"
+ unlike = post.unlike('test@testermcgee.com','dontrevealmysecrets')
+ assert unlike.is_a? Weary::Request
+ assert_equal 'http://www.tumblr.com/api/unlike', unlike.uri.to_s
end
test 'publishes to tumblr' do
klass = Class.new Tumblr::Post
post = klass.new