Fix dynamic multi-byte utf-8 files rebuilding.

Thor compares the new contents with the existing file by using
File.binread(destination) == new_content.
File.binread returns a string with ASCII_8BIT encoding, which will not
match the new_content if new_content contains multi-byte utf-8.

This patch simply encodes the new_content to ASCII_8BIT before passing
it to Thor.
This commit is contained in:
Kevin McCarthy 2013-03-03 18:13:41 -08:00
parent de955aa0c3
commit 7608275089
3 changed files with 35 additions and 1 deletions

View file

@ -1,5 +1,9 @@
require 'fileutils'
Before do
@modification_times = Hash.new
end
Given /^app "([^\"]*)" is using config "([^\"]*)"$/ do |path, config_name|
target = File.join(PROJECT_ROOT_PATH, "fixtures", path)
config_path = File.join(current_dir, "config-#{config_name}.rb")
@ -50,6 +54,16 @@ Given /^a successfully built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path,
step %Q{was successfully built}
end
Given /^a modification time for a file named "([^\"]*)"$/ do |file|
target = File.join(current_dir, file)
@modification_times[target] = File.mtime(target)
end
Then /^the file "([^\"]*)" should not have been updated$/ do |file|
target = File.join(current_dir, file)
File.mtime(target).should == @modification_times[target]
end
# Provide this Aruba overload in case we're matching something with quotes in it
Then /^the file "([^"]*)" should contain '([^']*)'$/ do |file, partial_content|
check_file_content(file, partial_content, true)