Hello, I''m trying to write a functional test for a simple CRUD controller which accepts / emits xml in a REST- like fashion. However the following code won''t work for me - an exception is generated def test_create post :create, ''<person><name>john</name></person>'', {''Content-Type''=>''application/xml''} assert_response 200 end Anyone give me a hint where I''m going wrong ? thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060505/3660b628/attachment.html
justin worrall wrote:> Hello, > > I''m trying to write a functional test for a simple CRUD controller which > accepts / emits xml in a REST- like fashion. However the following code > won''t work for me - an exception is generated > > def test_create > post :create, ''<person><name>john</name></person>'', > {''Content-Type''=>''application/xml''} > assert_response 200 > end > > Anyone give me a hint where I''m going wrong ? > > thanks in advanceI''m not sure how to fix it but I believe you stuck that xml in the post query string, not the post body. And if "an exception is generated" then it would be good to knwo the details of said exception. -- Posted via http://www.ruby-forum.com/.
> If "an exception is generated" then it would be good to knwo thedetails of said exception. Sorry - here it is 1) Error: test_create(PersonControllerTest): NoMethodError: undefined method `symbolize_keys'' for "<person><name>John</name></persion>":String /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/test_process.rb:99:in `assign_parameters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/test_process.rb:358:in `process'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/test_process.rb:336:in `post'' test/functional/person _controller_test.rb:21:in `test_person''> I''m not sure how to fix it but I believe you stuck that xml in the postquery string, not the post body. I agree, that looks likely. Can someone tell me how to add data to the post body, or point me in the direction of the approproate docs ? thanks.>* Hello,*>* *>* I''m trying to write a functional test for a simple CRUD controller which *>* accepts / emits xml in a REST- like fashion. However the following code *>* won''t work for me - an exception is generated *>* *>* def test_create *>* post :create, ''<person><name>john</name></person>'', *>* {''Content-Type''=>''application/xml''} *>* assert_response 200 *>* end **> thanks in advance* -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060506/d2d47991/attachment.html
justin worrall wrote:> 1) Error: > test_create(PersonControllerTest): > NoMethodError: undefined method `symbolize_keys'' for > "<person><name>John</name></persion>":StringYes, it definately wants a hash in that spot, not a string. Maybe the rails post method simply doesnt support request bodies? If so, that would be sad, as there would be no way to test REST. I''m eagerly awaiting the solution to this as well. -- Posted via http://www.ruby-forum.com/.