【发布时间】:2011-10-13 16:39:13
【问题描述】:
我已经设置了一个黄瓜套件来读取静态 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 读入临时文件?
【问题讨论】:
-
我认为这一定是 capybara、cucumber、ruby 1.8.7 或这三者的某种组合中的错误。我在 gemfile 中明确地将我的 cucumber、cucumber-rails、capybara 和 gherkin gem 回滚到早期版本,现在我的测试再次运行。
标签: ruby-on-rails cucumber capybara osx-lion