[rspec-users] [Story] passing a file using post

Andrew WC Brown omen.king at gmail.com
Wed Sep 26 15:14:26 EDT 2007


I'm trying to run a story for sample caboose that I created.
I haven't changed any of the sample application code.

When I try to do the following:

When "creating a new asset named",
File.open('/Users/multimedia/desktop/sample/assets/bridge.jpg')
do |path|
  post_via_redirect "/users/#{@user.login}/assets", :asset => {
:uploaded_data => path }
end

Processing UserAssetsController#create (for 127.0.0.1 at 2007-09-26
14:49:10) [POST]
  Session ID: d7b173a79b7f1382dc3b037c73608233
  Parameters: {"action"=>"create", "controller"=>"user_assets",
"user_id"=>"Andrew", "asset"=>{"uploaded_data"=>"#<File:0x326eaf0>"}}
  User Load (1) (0.002464)   SELECT * FROM users WHERE (users.`id` = 20)
LIMIT 1
  User Load (1) (0.002417)   SELECT * FROM users WHERE (users.`login` =
'Andrew') LIMIT 1
  Asset Columns (12) (0.004395)   SHOW FIELDS FROM assets


Processing UserAssetsController#create (for 127.0.0.1 at 2007-09-26
14:49:11) [POST]
  Session ID: d7b173a79b7f1382dc3b037c73608233
  Parameters: {"action"=>"create", "controller"=>"user_assets",
"user_id"=>"Andrew", "asset"=>{"uploaded_data"=>"#<File:0x326eaf0>"}}
undefined method `content_type' for "#<File:0x326eaf0>":String

If I launch the console and try the following line:

app.post "users/admin/assets", :asset => { :uploaded_data =>
File.open('/Users/multimedia/desktop/sample/assets/bridge.jpg')
}

I get:

Processing UserAssetsController#create (for 127.0.0.1 at 2007-09-25
23:47:36) [POST]
  Session ID: e23542c4871504f64044a25d8d49871b
  Parameters: {"action"=>"create", "controller"=>"user_assets",
"user_id"=>"admin", "asset"=>{"uploaded_data"=>"#<File:0x36a68ac>"}}

ArgumentError (A copy of AuthenticatedSystem has been removed from the
module tree but is still active!):

Any ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070926/5d2e93da/attachment.html 


More information about the rspec-users mailing list