mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-14 02:34:17 +02:00
Fix encoding test, then make tests actually fail.
This commit is contained in:
10
Rakefile
10
Rakefile
@@ -1,11 +1,19 @@
|
|||||||
task default: %w[test]
|
task default: %w[test]
|
||||||
|
|
||||||
task :test do
|
task :test do
|
||||||
|
failed = false
|
||||||
Dir["./tests/*.rb"].each do |test_file|
|
Dir["./tests/*.rb"].each do |test_file|
|
||||||
begin
|
begin
|
||||||
ruby test_file
|
ruby test_file
|
||||||
|
puts ""
|
||||||
rescue
|
rescue
|
||||||
puts "FAILED #{test_file}!"
|
puts "FAILED #{test_file}!"
|
||||||
|
puts ""
|
||||||
|
failed = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if failed
|
||||||
|
exit 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@@ -9,16 +9,21 @@ markdown_files.each do |file|
|
|||||||
case detection[:encoding]
|
case detection[:encoding]
|
||||||
when 'UTF-8'
|
when 'UTF-8'
|
||||||
$file_count = $file_count + 1
|
$file_count = $file_count + 1
|
||||||
when 'ISO-8859-1'
|
|
||||||
$file_count = $file_count + 1
|
|
||||||
else
|
else
|
||||||
puts "#{file} was detected as #{detection[:encoding]} encoding! Please save the file in UTF-8!"
|
enc = detection[:encoding]
|
||||||
|
if not enc.start_with? 'ISO-8859-'
|
||||||
|
puts "#{file} was detected as #{detection[:encoding]} encoding! Please save the file in UTF-8!"
|
||||||
|
else
|
||||||
|
$file_count += 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
rescue Exception => msg
|
rescue Exception => msg
|
||||||
puts msg
|
puts msg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
files_failed = markdown_files.length - $file_count
|
files_failed = markdown_files.length - $file_count
|
||||||
|
|
||||||
if files_failed != 0
|
if files_failed != 0
|
||||||
puts "FAILURE!!! #{files_failed} files were unable to be validated as UTF-8!"
|
puts "FAILURE!!! #{files_failed} files were unable to be validated as UTF-8!"
|
||||||
puts "Please resave the file as UTF-8."
|
puts "Please resave the file as UTF-8."
|
||||||
|
Reference in New Issue
Block a user