0
我正在写它使用DragonFly gem来处理附件,在这里一个表单页面一个规范时失败是我的规格(它的相关部分)水豚规范使用attach_file蜻蜓
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\
我做错了返回的第一个数据的二进制数据?这是我的错,还是与水豚和蜻蜓有一些不兼容?
P.S.当我使用真正的浏览器访问应用程序时,它就像一个魅力。