Strange attach_file bug

4 views
Skip to first unread message

Rick DeNatale

unread,
Nov 20, 2009, 2:11:01 PM11/20/09
to cu...@googlegroups.com, web...@googlegroups.com
cucumber (0.4.3)
webrat (0.5.1)
rails (2.3.4)

I'm trying to use the attach_file webrat function in a cucumber step.

For some reason, when the upload getting to the controller, instead of
the attachment being a TestUploadedFile instance, it looks like an
inspect string:

And I fill in "Add a Comment" with "my vacation pix"
# features/step_definitions/webrat_steps.rb:32
And I add the reply attachment "vacation.txt"
# features/step_definitions/notes_steps.rb:26
And I press "Add Comment"
# features/step_definitions/webrat_steps.rb:20
undefined method `each' for #<String:0x00000107785980> (NoMethodError)

The relevant step is:

When /^I add the reply attachment "([^\"]*)"$/ do |path|
attach_file("attachment[]", File.join(RAILS_ROOT,
'features/upload_files', path))
end

I had the controller print out what it was getting for the attachments
parameter

attachments is "[#<ActionController::TestUploadedFile:0x000001077a5880
@content_type=#<Mime::Type:0x00000100ec6c80 @synonyms=[],
@symbol=:text, @string="text/plain">,
@original_filename="vacation.txt",
@tempfile=#<File:/var/folders/DV/DVi3x+y8HiSSTCLkEYVBpE+++TI/-Tmp-/vacation.txt20091120-58509-2pjvnh-0>>]"

The controller code actually works so this appears to be some problem
with the cucumber/webrat/rails integration test stack.

Any ideas?


--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

Reply all
Reply to author
Forward
0 new messages