forked from nanoc/nanoc
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e1afac
commit 86f228c
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|