Skip to content

Instantly share code, notes, and snippets.

@tonycosentini
Created May 2, 2011 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonycosentini/951779 to your computer and use it in GitHub Desktop.
Save tonycosentini/951779 to your computer and use it in GitHub Desktop.
Tumblr to Jekyll Tests
require 'rubygems'
gem 'RedCloth', '>= 4.2.1'
require 'RedCloth'
require 'rdiscount'
require 'kramdown'
require 'test/unit'
require 'redgreen'
require 'shoulda'
require 'rr'
require 'fileutils'
require 'tumblr'
class TestTumblr < Test::Unit::TestCase
context "Import from test site" do
setup do
Jekyll::Tumblr.process('http://jekyllmigrate.tumblr.com')
end
should "have 17 posts" do
assert_equal 17, Dir.new("_posts/tumblr").entries.size - 2
end
should "have correct filenames" do
files = %w{2011-05-01-5117275287.html 2011-05-01-5117278881.html
2011-05-01-5117300822.html 2011-05-01-5117310310.html
2011-05-01-5117325159.html 2011-05-01-5117328260.html
2011-05-01-5117342746.html 2011-05-01-5117348442.html
2011-05-01-5117366904.html 2011-05-01-5117379464.html
2011-05-01-5117384266.html 2011-05-01-5117417255.html
2011-05-01-5117428352.html 2011-05-01-5117458809.html
2011-05-01-5117468042.html 2011-05-01-5117479769.html
2011-05-01-5117484063.html}
Dir.new("_posts/tumblr").entries.each do |file|
unless file == "." || file == ".."
assert files.include? file
end
end
end
should "have the correct contents" do
sizes = [507, 496, 304, 283, 171, 158, 138, 202, 138, 66, 79, 44, 63, 114, 53, 57, 57]
i = 0
Dir.new("_posts/tumblr").entries.each do |file|
unless file == "." || file == ".."
assert sizes[i] == File.size?("_posts/tumblr/#{file}")
i+=1
end
end
end
teardown do
FileUtils.remove_dir "_posts"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment