diff --git a/test/source/_urls_differ_by_case_invalid/page1.html b/test/source/_urls_differ_by_case_invalid/page1.html new file mode 100644 index 00000000..a6a79f93 --- /dev/null +++ b/test/source/_urls_differ_by_case_invalid/page1.html @@ -0,0 +1,6 @@ +--- +title: About +permalink: /about/ +--- + +About the site diff --git a/test/source/_urls_differ_by_case_invalid/page2.html b/test/source/_urls_differ_by_case_invalid/page2.html new file mode 100644 index 00000000..21f679f3 --- /dev/null +++ b/test/source/_urls_differ_by_case_invalid/page2.html @@ -0,0 +1,6 @@ +--- +title: About +permalink: /About/ +--- + +About the site diff --git a/test/source/_urls_differ_by_case_valid/page1.html b/test/source/_urls_differ_by_case_valid/page1.html new file mode 100644 index 00000000..a6a79f93 --- /dev/null +++ b/test/source/_urls_differ_by_case_valid/page1.html @@ -0,0 +1,6 @@ +--- +title: About +permalink: /about/ +--- + +About the site diff --git a/test/test_doctor_command.rb b/test/test_doctor_command.rb new file mode 100644 index 00000000..43fa602c --- /dev/null +++ b/test/test_doctor_command.rb @@ -0,0 +1,36 @@ +require 'helper' +require 'jekyll/commands/doctor' + +class TestDoctorCommand < Test::Unit::TestCase + context 'urls only differ by case' do + setup do + clear_dest + end + + should 'return success on a valid site/page' do + @site = Site.new(Jekyll.configuration({ + "source" => File.join(source_dir, '/_urls_differ_by_case_valid'), + "destination" => dest_dir + })) + @site.process + output = capture_stderr do + ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) + assert_equal false, ret + end + assert_equal "", output + end + + should 'return warning for pages only differing by case' do + @site = Site.new(Jekyll.configuration({ + "source" => File.join(source_dir, '/_urls_differ_by_case_invalid'), + "destination" => dest_dir + })) + @site.process + output = capture_stderr do + ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) + assert_equal true, ret + end + assert_equal "\e[33m Warning: The following URLs only differ by case. On a case-insensitive file system one of the URLs will be overwritten by the other: #{dest_dir}/about/index.html, #{dest_dir}/About/index.html\e[0m\n", output + end + end +end