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
このエラーを追跡したところ、この行で発生していることがわかりました。その行の前にいくつかのデバッグ命令を置いたところ、画像のバイナリ データを含むことobj
がわかりました。Array
p obj.inspect
"[\"\\x89PNG\\r\\n\", \"\\u001A\\n\", \"\\u0000\\u0000\\u0000\\rIHDR\\u0000\\u0000\\u0003s\
私が間違っていることは何ですか?それは私のせいですか、それともカピバラとトンボとの非互換性がありますか?
PS実際のブラウザを使用してアプリケーションにアクセスすると、魅力的に機能します。