Forum: Ruby on Rails Where's the doc for get(), post(), put(), delete() & head()?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Stephen A. (Guest)
on 2006-03-25 04:44
These HTTP Request methods are used for testing.  They are discussed in
the testing chapter of the Agile Web D. with Rails book, as
well as in http://manuals.rubyonrails.com/read/chapter/28#page72 "A
Guide to Testing the Rails".

I want to set the encoding to multipart for a test I'm writing, but I
can't find any documentation to show me how.  Pointing me to the source
code for the methods would be just as good.

I've looked all over, and spent a good amount of time searching, so your
help is greatly appreciated!

Thanks!
anne001 (Guest)
on 2006-03-25 13:02
(Received via mailing list)
Maybe you have been looking in the wrong place?

I would look for info on those fx like this
get() +http request methods

http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2
http://wdvl.com/Internet/Protocols/HTTP/Request.html
etc

I would also look for
"multipart/form-data" +"http request methods"
found a site to do with ruby I think:
parse talks about multi/parts encoding

this gives an example with method post
http://users.easystreet.com/ovid/cgi_course/lesson...
http://wiki.modruby.net/en/?Apache%3A%3ARequest

I have not used forms much, so I am just giving you my ideas on how to
search
--
View this message in context:
http://www.nabble.com/Where%27s-the-doc-for-get%28...
Sent from the RubyOnRails Users forum at Nabble.com.
Stephen A. (Guest)
on 2006-03-25 21:48
Thanks for the answer Anne, but I guess I needed to be more specific.

What I'm looking for is the RDOC for the Ruby methods that are shown in
the testing chapter of the Agile Web D. with Rails book.
Finding the Ruby source code for the methods would also work.

I know enough about the HTTP methods, just not enough about the actual
Rails/Ruby method call arguments.

Thanks!
-Steve-

anne001 wrote:
> Maybe you have been looking in the wrong place?
>
> I would look for info on those fx like this
> get() +http request methods
>
> http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2
> http://wdvl.com/Internet/Protocols/HTTP/Request.html
> etc
>
> I would also look for
> "multipart/form-data" +"http request methods"
> found a site to do with ruby I think:
> parse talks about multi/parts encoding
>
> this gives an example with method post
> http://users.easystreet.com/ovid/cgi_course/lesson...
> http://wiki.modruby.net/en/?Apache%3A%3ARequest
>
> I have not used forms much, so I am just giving you my ideas on how to
> search
> --
> View this message in context:
> 
http://www.nabble.com/Where%27s-the-doc-for-get%28...
> Sent from the RubyOnRails Users forum at Nabble.com.
Alex Y. (Guest)
on 2006-03-26 14:02
(Received via mailing list)
Stephen A. wrote:
> help is greatly appreciated!
Unfortunately there's no Rdoc for those methods, because they're
generated in a way that the Rdoc processor can't pick up.  Deeply
irritating, but I've got them in
actionpack-1.11.2/action_controller/test_process.rb.  Look for:

   %w( get post put delete head ).each do |method|
     class_eval <<-EOV, __FILE__, __LINE__

There's an entry in the wiki for testing uploaded files that might be
relevant - I'd suggest having a quick google if that's what you're
trying to do.  There's some monkeying with CGI, if I remember correctly.
anne001 (Guest)
on 2006-03-26 16:40
(Received via mailing list)
http://www.ruby-doc.org/stdlib/libdoc/net/http/rdo...

this is a ruby doc, it has all the key word you asked for, do you think
you
are looking for something like that?
--
View this message in context:
http://www.nabble.com/Where%27s-the-doc-for-get%28...
Sent from the RubyOnRails Users forum at Nabble.com.
Alex Y. (Guest)
on 2006-03-26 16:47
(Received via mailing list)
anne001 wrote:
> http://www.ruby-doc.org/stdlib/libdoc/net/http/rdo...
>
> this is a ruby doc, it has all the key word you asked for, do you think you
> are looking for something like that?
Given the context, I think he's after Test::Unit::TestCase.{put, post,
get} rather that Net::HTTP.{put, post, get}.
Stephen A. (Guest)
on 2006-03-27 00:48
Yes, this is exactly what I was looking for.  I can see why the RDOC
didn't pick it up.

Unfortunately, I haven't been able to determine how to set encoding to
'multipart/form-data' by reading this code yet.

The wiki page on testing uploaded files doesn't cover testing
file_column uploaded files at this point.  I'll add my question to the
Wiki page, as well as any answer I come up with.  When I tried to follow
those instructions, the code failed miserably.  An experiment I did
makes me think that I might be able to set that field to a string, and
set the post to multipart.

My experimenting so far, make me think that if your code uses the
file_column plugin, then you ought to be able to do something like this:

    member_properties[:image_path] = image_path
    post :create, {:member => member_properties},
       :encoding => multipart/form-data'

But no matter what I do, the test returns
"test_add_valid_member_with_image(AddMemberTest):
TypeError: Do not know how to handle a string with value
'/Users/stephen/mi7/test/fixtures/images/DiamondsAndRust.jpg' that was
passed to a file_column. Check if the form's encoding has been set to
'multipart/form-data'.

Maybe I'm barking up the wrong tree...

But thanks for your help regardless!
-Steve-

Alex Y. wrote:
> Stephen A. wrote:
>> help is greatly appreciated!
> Unfortunately there's no Rdoc for those methods, because they're
> generated in a way that the Rdoc processor can't pick up.  Deeply
> irritating, but I've got them in
> actionpack-1.11.2/action_controller/test_process.rb.  Look for:
>
>    %w( get post put delete head ).each do |method|
>      class_eval <<-EOV, __FILE__, __LINE__
>
> There's an entry in the wiki for testing uploaded files that might be
> relevant - I'd suggest having a quick google if that's what you're
> trying to do.  There's some monkeying with CGI, if I remember correctly.
This topic is locked and can not be replied to.