I am working on a project with Sitespec, which is a static site generator using RSpec and uses any Rack app. I chose Padrino as a Rack app for Sitespec.
Then, I get the following errors when I do rspec
at some URLs of Content-type: image/png
type.
Failures:
1) Sitespec GET public/images/simple-image1.png Generate a static image public/images/simple-image1.png
Failure/Error: pathname.write(response.body)
Encoding::UndefinedConversionError:
"\x89" from ASCII-8BIT to UTF-8
Pathname.write(response.body)
is going to try to convert it to UTF-8.
But when I use Sinatra instead of Padrino, the error does not occur.
I made simple sample projects for comparison:
- Using Padrino https://github.com/Nyoho/sitespec-padrino-sample2
- Using Sinatra https://github.com/Nyoho/simple-sitespec-sinatra-test
Question: Why does the Padrino project fail and how do I fix the errors?
By the way, doing monkey patch
module Sitespec
class Artifact
def generate_file
pathname.binwrite(response.body)
end
end
end
eliminates the error. (Replacing Pathname#write
to Pathname#binwrite
.)