Skip to content

Commit

Permalink
added stale checker test case
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Oct 14, 2012
1 parent 6e1afac commit 86f228c
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions test/extra/checking/checkers/test_stale.rb
@@ -0,0 +1,49 @@
# encoding: utf-8

class Nanoc::Extra::Checking::Checkers::StaleTest < MiniTest::Unit::TestCase

include Nanoc::TestHelpers

def checker_class
Nanoc::Extra::Checking::Checkers::Stale
end

def calc_issues
site = Nanoc::Site.new('.')
checker = checker_class.new(site)
checker.run
checker.issues
end

def test_run_ok
with_site do |site|
assert Dir['content/*'].empty?
assert Dir['output/*'].empty?

# Empty
FileUtils.mkdir_p('output')
assert self.calc_issues.empty?

# One OK file
File.write('content/index.html', 'stuff')
File.write('output/index.html', 'stuff')
assert self.calc_issues.empty?
end
end

def test_run_error
with_site do |site|
assert Dir['content/*'].empty?
assert Dir['output/*'].empty?

File.write('content/index.html', 'stuff')
File.write('output/WRONG.html', 'stuff')
assert_equal 1, self.calc_issues.count
issue = self.calc_issues.to_a[0]
assert_equal "file without matching item", issue.description
assert_equal "output/WRONG.html", issue.subject
end
end

end

0 comments on commit 86f228c

Please sign in to comment.