Re: [Rails] Re: functional testing API: GET versus POST?

2011-11-07 Thread Rob Biedenharn
On Nov 6, 2011, at 4:35 PM, Grary Stimon wrote: request = 4_000_000 post :loan, {:loan_request=>request, :format => :json} ...finally the test log of the request is... Processing by Sec223fAcquisitionController#loan as JSON The influence of the :format=>:json bit is ...^^here^^. If

Re: [Rails] Re: functional testing API: GET versus POST?

2011-11-06 Thread Dave Aronson
On Sun, Nov 6, 2011 at 17:24, Grary Stimon wrote: >    request = 4_000_000 >    post :loan, {:loan_request=>request, :format => :json} > > ...is not formulating the request as JSON? Correct. This is exactly why you're getting: > (rdb:1) p request.body.read > "loan=400" I'm wondering thoug

Re: [Rails] Re: functional testing API: GET versus POST?

2011-11-06 Thread Dave Aronson
On Sun, Nov 6, 2011 at 16:35, Grary Stimon wrote: > What bugs me here is that I don't see the JSON format appear anywhere > above. I understand why the parser would choke on > 'loan_request=400', because it's not JSON. Exactly. You're telling it to parse the stuff as JSON, but you're not se

[Rails] Re: functional testing API: GET versus POST?

2011-11-06 Thread Grary Stimon
Colin, Here's some of the debug trace... => 14 data = ActiveSupport::JSON.decode(request.body.read) (rdb:1) p request.body.read "loan=400" So, this is consistent with the controller error.. JSON::ParserError: unexpected token at 'loan_request=400' My functional testing approa

Re: [Rails] Re: functional testing API: GET versus POST?

2011-11-06 Thread Colin Law
On 6 November 2011 21:35, Grary Stimon wrote: > Dave, > > Thanks for the consideration you show to this issue of mine, here is the > recap... > > I have the following error from my Rails 3.1 controller... > >    JSON::ParserError: unexpected token at 'loan_request=400' > > ...where the control

[Rails] Re: functional testing API: GET versus POST?

2011-11-06 Thread Grary Stimon
Dave, Thanks for the consideration you show to this issue of mine, here is the recap... I have the following error from my Rails 3.1 controller... JSON::ParserError: unexpected token at 'loan_request=400' ...where the controller code line in question is... data = ActiveSupport::JSO

Re: [Rails] Re: functional testing API: GET versus POST?

2011-11-06 Thread Dave Aronson
On Sun, Nov 6, 2011 at 10:10, Grary Stimon wrote: > Sorry to promote this again, but I'm stuck. Anybody? Those of us who read this via normal email don't have prior context. Please recap (briefly) what problem you're trying to get help with. Thanks, Dave -- LOOKING FOR WORK! What: Ruby (on/of

[Rails] Re: functional testing API: GET versus POST?

2011-11-06 Thread Grary Stimon
Hey, Sorry to promote this again, but I'm stuck. Anybody? Grar -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubs

[Rails] Re: functional testing API: GET versus POST?

2011-11-05 Thread Grary Stimon
Matt, Thanks. Continued work on this problem has shifted the emphasis, but I'm still blocked and could use help. I've changed the request from a GET to a POST, just to remove uncertainty around the availability of the request.body for processing in the controller. I now have the following error

[Rails] Re: functional testing API: GET versus POST?

2011-11-05 Thread Matt Jones
On Nov 4, 6:10 pm, Grary Stimon wrote: > Hi, > > I'm unable to properly test GET calls for my JSON API in Rails 3.1, > using ActionController::TestCase. > > get :loan, ActiveSupport::JSON.encode(minimum_valid_json_params), > :format => :json > > ...where minimum_valid_json_params has the form...