我已经设置了一个黄瓜套件来读取静态 PDF 文件并对其内容进行断言。
我最近更新了我所有的宝石,自从这样做之后,它就不再起作用了。
黄瓜步骤如下:
When /^I follow PDF link "([^"]*)"$/ do |arg1|
temp_pdf = Tempfile.new('foo')
temp_pdf << page.body
temp_pdf.close
temp_txt = Tempfile.new('txt')
temp_txt.close
'pdftotext -q #{temp_pdf.path} #{temp_txt.path}'
page.drive.instance_variable_set('@body', File.read(temp_txt.path))
end
这曾经工作得很好。但是在更新到 Lion/my gems 后,执行该行时会引发以下错误temp_pdf << page.body
encoding error: output conversion failed due to conv error, bytes 0xA3 0xC3 0x8F 0xC3
I/O error : encoder error
我尝试了一些来自不同来源的不同 PDF,但它们似乎都失败了。如何将 PDF 读入临时文件?