Sha256: 9ea6e02107ad824750b77298ca5661118508e9aea0c9eb393b2479f9bfa0b3b2

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

# encoding: utf-8

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

  include Nanoc::TestHelpers

  def check_class
    Nanoc::Extra::Checking::Checks::Stale
  end

  def calc_issues
    site = Nanoc::Site.new('.')
    check = check_class.new(site)
    check.run
    check.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.open('content/index.html', 'w') { |io| io.write('stuff') }
      File.open('output/index.html', 'w') { |io| io.write('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.open('content/index.html', 'w') { |io| io.write('stuff') }
      File.open('output/WRONG.html', 'w') { |io| io.write('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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nanoc-3.5.0 test/extra/checking/checks/test_stale.rb
nanoc-3.5.0b2 test/extra/checking/checks/test_stale.rb
nanoc-3.5.0b1 test/extra/checking/checks/test_stale.rb