forked from nanoc/nanoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_stale.rb
49 lines (38 loc) · 1.11 KB
/
test_stale.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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