New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail checks when output directory is not present #472

Merged
merged 2 commits into from Sep 6, 2014
Jump to file or symbol
Failed to load files and symbols.
+21 −1
Diff settings

Always

Just for now

Next

Fail checks when output directory is not present

Currently, site checks pass when the output directory is not present.
Ensure that all checks fail in cases where there is no generated site
content to validate.
  • Loading branch information...
jugglinmike committed Sep 3, 2014
commit 78be40349bf8d11c2d46a05ea822925b386fd85d
@@ -2,6 +2,12 @@
module Nanoc::Extra::Checking
class OutputDirNotFoundError < Nanoc::Errors::Generic
def initialize(directory_path)
super("Unable to run check against output directory at “#{directory_path}”: directory does not exist.")
end
end
class Check
extend Nanoc::PluginRegistry::PluginMethods
@@ -25,7 +31,11 @@ def add_issue(desc, params = {})
end
def output_filenames
Dir[@site.config[:output_dir] + '/**/*'].select { |f| File.file?(f) }
output_dir = @site.config[:output_dir]
unless File.exists? output_dir

This comment has been minimized.

@ddfreyne

ddfreyne Sep 5, 2014

Member

Can you add method call parens here, and rename exists to exist?

unless File.exists? output_dir

should be

unless File.exist?(output_dir)
@ddfreyne

ddfreyne Sep 5, 2014

Member

Can you add method call parens here, and rename exists to exist?

unless File.exists? output_dir

should be

unless File.exist?(output_dir)

This comment has been minimized.

@jugglinmike

jugglinmike Sep 5, 2014

Contributor

Sure!

@jugglinmike

jugglinmike Sep 5, 2014

Contributor

Sure!

raise Nanoc::Extra::Checking::OutputDirNotFoundError.new(output_dir)
end
Dir[output_dir + '/**/*'].select { |f| File.file?(f) }
end
end
@@ -11,4 +11,14 @@ def test_output_filenames
end
end
def test_no_output_dir
with_site do |site|
site.config[:output_dir] = 'non-existent'
check = Nanoc::Extra::Checking::Check.new(site)
assert_raises Nanoc::Extra::Checking::OutputDirNotFoundError do
check.output_filenames
end
end
end
end
ProTip! Use n and p to navigate between commits in a pull request.