【发布时间】:2011-11-17 09:56:50
【问题描述】:
我正在为使用DragonFly gem 处理附件的表单页面编写规范,这是我的规范(相关部分)
fill_in "Subject", :with => 'My message'
fill_in "Title", :with => 'My image title'
fill_in "Content", :with => 'Message content'
attach_file 'Title image', Rails.root.join('spec', 'factories', 'test-image.png')
click_button "Create Message"
page.should have_content("Message was successfully created.")
但是它在click_button 步骤中失败并出现以下错误
Failure/Error: click_button "Create Message"
ArgumentError:
Dragonfly::TempObject must be initialized with a String, a Pathname, a File, a Tempfile, another TempObject, something that responds to .tempfile, or something that responds to .path
我追踪了这个错误,发现它是在this line 中提出的;我在那行之前放了一些调试指令,我发现obj是一个Array,其中包含图像的二进制数据,这是p obj.inspect返回的第一个数据
"[\"\\x89PNG\\r\\n\", \"\\u001A\\n\", \"\\u0000\\u0000\\u0000\\rIHDR\\u0000\\u0000\\u0003s\
我做错了什么?是我的错还是水豚和蜻蜓有些不兼容?
附:当我使用真正的浏览器访问应用程序时,它就像一个魅力。
【问题讨论】:
标签: ruby ruby-on-rails-3 rspec capybara dragonfly-gem