apneadiving
2012-Jan-05 23:45 UTC
[rspec-users] why is ''get :index, :page => 2'' different from ''get :index, :page => "2"''
Hi, After coding my app and enjoying a green wave of tests, I had horrible feedback about some bugs. Those bugs happened to some well tested parts of my app. After some research, I found out that get :index, :page => 2, :per_page => 5 is different from: get :index, :page => "2", :per_page => "5" So I simply missed some ''to_i'' in my controller. I thought, the ''get'' parameters would have been stringified, like it is in a standard request. Why is it not the case?
David Chelimsky
2012-Jan-05 23:55 UTC
[rspec-users] why is ''get :index, :page => 2'' different from ''get :index, :page => "2"''
On Thu, Jan 5, 2012 at 5:45 PM, apneadiving <apnea.diving.deep at gmail.com> wrote:> Hi, > > After coding my app and enjoying a green wave of tests, I had horrible > feedback about some bugs. > > Those bugs happened to some well tested parts of my app. > > After some research, I found out that > > get :index, :page => 2, :per_page => 5 > > is different from: > > get :index, :page => "2", :per_page => "5" > > So I simply missed some ''to_i'' in my controller. > > I thought, the ''get'' parameters would have been stringified, like it > is in a standard request.That''s what I thought too! https://github.com/rails/rails/pull/1203> > Why is it not the case?It is, depending on what version of Rails you''re using. Don''t remember which version included my patch(es), but I *think* it was 3.1. HTH, David
apneadiving
2012-Jan-06 00:08 UTC
[rspec-users] why is ''get :index, :page => 2'' different from ''get :index, :page => "2"''
On Jan 6, 12:55?am, David Chelimsky <dchelim... at gmail.com> wrote:> On Thu, Jan 5, 2012 at 5:45 PM, apneadiving <apnea.diving.d... at gmail.com> wrote: > > Hi, > > > After coding my app and enjoying a green wave of tests, I had horrible > > feedback about some bugs. > > > Those bugs happened to some well tested parts of my app. > > > After some research, I found out that > > > get :index, :page => 2, :per_page => 5 > > > is different from: > > > get :index, :page => "2", :per_page => "5" > > > So I simply missed some ''to_i'' in my controller. > > > I thought, the ''get'' parameters would have been stringified, like it > > is in a standard request. > > That''s what I thought too! > > https://github.com/rails/rails/pull/1203 > > > > > Why is it not the case? > > It is, depending on what version of Rails you''re using. Don''t remember > which version included my patch(es), but I *think* it was 3.1. > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-usersYou definitely rock. Thanks a bunch for this neat & quick answer :)