params are making my "should redirect_to" test fail - why??

View: New views
14 Messages — Rating Filter:   Alert me  

params are making my "should redirect_to" test fail - why??

by Max Williams :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm testing a controller action that redirects to a different action/view, sending through some params.  In my test, i'm only specifying the controller and action that it should redirect to, but the additional params are making it fail!  Here's my test:

  it "should redirect to batch_saved after completing batch_save" do
    post 'batch_save', @params
    response.should redirect_to(:controller => 'admin/users', :action => 'batch_saved')
  end  

and here's the failure report:

'Admin::UserController When logged in as an admin level user should redirect to batch_saved after batch_save' FAILED
expected redirect to {:controller=>"admin/users", :action=>"batch_saved"}, got redirect to "http://test.host/admin/users/batch_saved?music_service_id=1&new_users%5B%5D%5Bemail%5D=mark%40zadeup.com&new_users%5B%5D%5Bfirstname%5D=Mark&new_users%5B%5D%5Bmusic_service_id%5D=1&new_users%5B%5D%5Bschool%5D=&new_users%5B%5D%5Bsurname%5D=Madeup"

Now, i would expect that since i'm just specifying a controller and action, and we redirect to them, that the test would pass.  But the params are breaking it (I know this because i changed the controller action to not send params through at all and the test passed).  How do i do the test so that it doesn't care about the params?  


Re: params are making my "should redirect_to" test fail - why??

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Feb 13, 2008 12:26 PM, Max Williams <toastkid.williams@...> wrote:

>
> I'm testing a controller action that redirects to a different action/view,
> sending through some params.  In my test, i'm only specifying the controller
> and action that it should redirect to, but the additional params are making
> it fail!  Here's my test:
>
>   it "should redirect to batch_saved after completing batch_save" do
>     post 'batch_save', @params
>     response.should redirect_to(:controller => 'admin/users', :action =>
> 'batch_saved')
>   end
>
> and here's the failure report:
>
> 'Admin::UserController When logged in as an admin level user should redirect
> to batch_saved after batch_save' FAILED
> expected redirect to {:controller=>"admin/users", :action=>"batch_saved"},
> got redirect to
> "http://test.host/admin/users/batch_saved?music_service_id=1&new_users%5B%5D%5Bemail%5D=mark%40zadeup.com&new_users%5B%5D%5Bfirstname%5D=Mark&new_users%5B%5D%5Bmusic_service_id%5D=1&new_users%5B%5D%5Bschool%5D=&new_users%5B%5D%5Bsurname%5D=Madeup"
>
> Now, i would expect that since i'm just specifying a controller and action,
> and we redirect to them, that the test would pass.  But the params are
> breaking it (I know this because i changed the controller action to not send
> params through at all and the test passed).  How do i do the test so that it
> doesn't care about the params?

When you use a hash it checks the whole hash, so this is the expected behaviour.

You can either used a named route (if you've got one available) or a
String literal:

response.should redirect_to(admin_users_batch_saved)
response.should redirect_to('/admin/users/batch_saved')

Based on Jay Field's latest advice
(http://blog.jayfields.com/2008/02/testing-expect-literals.html) you
may want to consider the literal.

HTH,
David


>
>
> --
> View this message in context: http://www.nabble.com/params-are-making-my-%22should-redirect_to%22-test-fail---why---tp15460582p15460582.html
> Sent from the rspec-users mailing list archive at Nabble.com.
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@...
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: params are making my "should redirect_to" test fail - why??

by Max Williams :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi David - thanks for replying.  The literal doesn't work either, because of all the params at the end, and i don't have named routes in this old, non-restful app.  I see your point about the hash...is there any way to get the redirected-to url from 'response' and test against that?  Then i could split it at "?" to ignore the params.  (I'd rather not include the specific params in this test since i really just want to know about where it's redirected to).

So, ideally i could do something like this -

response.url.split("?").first.should eql("http://test.host/admin/users/batch_saved")

I've been looking for documentation for methods for the response object, to get the url, but i can't find any in the api docs (i'm probably just looking in the wrong place).  I can see the url data in the object but it's private.

thanks
max

On 13/02/2008, David Chelimsky <dchelimsky@...> wrote:
On Feb 13, 2008 12:26 PM, Max Williams <toastkid.williams@...> wrote:
>
> I'm testing a controller action that redirects to a different action/view,
> sending through some params.  In my test, i'm only specifying the controller
> and action that it should redirect to, but the additional params are making
> it fail!  Here's my test:
>
>   it "should redirect to batch_saved after completing batch_save" do
>     post 'batch_save', @params
>     response.should redirect_to(:controller => 'admin/users', :action =>
> 'batch_saved')
>   end
>
> and here's the failure report:
>
> 'Admin::UserController When logged in as an admin level user should redirect
> to batch_saved after batch_save' FAILED
> expected redirect to {:controller=>"admin/users", :action=>"batch_saved"},
> got redirect to
> "http://test.host/admin/users/batch_saved?music_service_id=1&new_users%5B%5D%5Bemail%5D=mark%40zadeup.com&new_users%5B%5D%5Bfirstname%5D=Mark&new_users%5B%5D%5Bmusic_service_id%5D=1&new_users%5B%5D%5Bschool%5D=&new_users%5B%5D%5Bsurname%5D=Madeup"
>
> Now, i would expect that since i'm just specifying a controller and action,
> and we redirect to them, that the test would pass.  But the params are
> breaking it (I know this because i changed the controller action to not send
> params through at all and the test passed).  How do i do the test so that it
> doesn't care about the params?


When you use a hash it checks the whole hash, so this is the expected behaviour.

You can either used a named route (if you've got one available) or a
String literal:

response.should redirect_to(admin_users_batch_saved)
response.should redirect_to('/admin/users/batch_saved')

Based on Jay Field's latest advice
(http://blog.jayfields.com/2008/02/testing-expect-literals.html) you
may want to consider the literal.

HTH,
David


>
>
> --

> View this message in context: http://www.nabble.com/params-are-making-my-%22should-redirect_to%22-test-fail---why---tp15460582p15460582.html
> Sent from the rspec-users mailing list archive at Nabble.com.
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@...
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users


_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: params are making my "should redirect_to" test fail - why??

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Feb 14, 2008 at 5:15 AM, Max Williams
<toastkid.williams@...> wrote:

> Hi David - thanks for replying.  The literal doesn't work either, because of
> all the params at the end, and i don't have named routes in this old,
> non-restful app.  I see your point about the hash...is there any way to get
> the redirected-to url from 'response' and test against that?  Then i could
> split it at "?" to ignore the params.  (I'd rather not include the specific
> params in this test since i really just want to know about where it's
> redirected to).
>
> So, ideally i could do something like this -
>
> response.url.split("?").first.should
> eql("http://test.host/admin/users/batch_saved")

Try response.redirect_url.

>
>  I've been looking for documentation for methods for the response object, to
> get the url, but i can't find any in the api docs (i'm probably just looking
> in the wrong place).  I can see the url data in the object but it's private.
>
> thanks
> max
>
>
>
> On 13/02/2008, David Chelimsky <dchelimsky@...> wrote:
> > On Feb 13, 2008 12:26 PM, Max Williams <toastkid.williams@...>
> wrote:
> > >
> > > I'm testing a controller action that redirects to a different
> action/view,
> > > sending through some params.  In my test, i'm only specifying the
> controller
> > > and action that it should redirect to, but the additional params are
> making
> > > it fail!  Here's my test:
> > >
> > >   it "should redirect to batch_saved after completing batch_save" do
> > >     post 'batch_save', @params
> > >     response.should redirect_to(:controller => 'admin/users', :action =>
> > > 'batch_saved')
> > >   end
> > >
> > > and here's the failure report:
> > >
> > > 'Admin::UserController When logged in as an admin level user should
> redirect
> > > to batch_saved after batch_save' FAILED
> > > expected redirect to {:controller=>"admin/users",
> :action=>"batch_saved"},
> > > got redirect to
> > >
> "http://test.host/admin/users/batch_saved?music_service_id=1&new_users%5B%5D%5Bemail%5D=mark%40zadeup.com&new_users%5B%5D%5Bfirstname%5D=Mark&new_users%5B%5D%5Bmusic_service_id%5D=1&new_users%5B%5D%5Bschool%5D=&new_users%5B%5D%5Bsurname%5D=Madeup"
> > >
> > > Now, i would expect that since i'm just specifying a controller and
> action,
> > > and we redirect to them, that the test would pass.  But the params are
> > > breaking it (I know this because i changed the controller action to not
> send
> > > params through at all and the test passed).  How do i do the test so
> that it
> > > doesn't care about the params?
> >
> >
> > When you use a hash it checks the whole hash, so this is the expected
> behaviour.
> >
> > You can either used a named route (if you've got one available) or a
> > String literal:
> >
> > response.should redirect_to(admin_users_batch_saved)
> > response.should redirect_to('/admin/users/batch_saved')
> >
> > Based on Jay Field's latest advice
> > (http://blog.jayfields.com/2008/02/testing-expect-literals.html) you
> > may want to consider the literal.
> >
> > HTH,
> > David
> >
> >
> > >
> > >
> > > --
> >
> > > View this message in context:
> http://www.nabble.com/params-are-making-my-%22should-redirect_to%22-test-fail---why---tp15460582p15460582.html
> > > Sent from the rspec-users mailing list archive at Nabble.com.
> > >
> > > _______________________________________________
> > > rspec-users mailing list
> > > rspec-users@...
> > > http://rubyforge.org/mailman/listinfo/rspec-users
> > >
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users@...
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
>
>
> _______________________________________________
>  rspec-users mailing list
>  rspec-users@...
>  http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: params are making my "should redirect_to" test fail - why??

by Rick DeNatale :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2/14/08, Max Williams <toastkid.williams@...> wrote:

> Hi David - thanks for replying.  The literal doesn't work either, because of
> all the params at the end, and i don't have named routes in this old,
> non-restful app.  I see your point about the hash...is there any way to get
> the redirected-to url from 'response' and test against that?  Then i could
> split it at "?" to ignore the params.  (I'd rather not include the specific
> params in this test since i really just want to know about where it's
> redirected to).
>
> So, ideally i could do something like this -
>
> response.url.split("?").first.should
> eql("http://test.host/admin/users/batch_saved")
>
>  I've been looking for documentation for methods for the response object, to
> get the url, but i can't find any in the api docs (i'm probably just looking
> in the wrong place).  I can see the url data in the object but it's private.

Well the RedirectTo matcher gets it using

    response.redirect_url

I'd probably write the check as

   response.should be_redirect
   response.redirect_url.should
match(%r{^http://test.host/admin/users/batch_saved(\?|$)})

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: params are making my "should redirect_to" test fail - why??

by Max Williams :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

perfect - that's the method i was looking for.  Thanks! 

On 14/02/2008, Rick DeNatale <rick.denatale@...> wrote:
On 2/14/08, Max Williams <toastkid.williams@...> wrote:
> Hi David - thanks for replying.  The literal doesn't work either, because of
> all the params at the end, and i don't have named routes in this old,
> non-restful app.  I see your point about the hash...is there any way to get
> the redirected-to url from 'response' and test against that?  Then i could
> split it at "?" to ignore the params.  (I'd rather not include the specific
> params in this test since i really just want to know about where it's
> redirected to).
>
> So, ideally i could do something like this -
>
> response.url.split("?").first.should
> eql("http://test.host/admin/users/batch_saved")
>
>  I've been looking for documentation for methods for the response object, to
> get the url, but i can't find any in the api docs (i'm probably just looking
> in the wrong place).  I can see the url data in the object but it's private.


Well the RedirectTo matcher gets it using

    response.redirect_url

I'd probably write the check as

   response.should be_redirect
   response.redirect_url.should
match(%r{^http://test.host/admin/users/batch_saved(\?|$)})


--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users


_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: params are making my "should redirect_to" test fail - why??

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale <rick.denatale@...> wrote:

> On 2/14/08, Max Williams <toastkid.williams@...> wrote:
>  > Hi David - thanks for replying.  The literal doesn't work either, because of
>  > all the params at the end, and i don't have named routes in this old,
>  > non-restful app.  I see your point about the hash...is there any way to get
>  > the redirected-to url from 'response' and test against that?  Then i could
>  > split it at "?" to ignore the params.  (I'd rather not include the specific
>  > params in this test since i really just want to know about where it's
>  > redirected to).
>  >
>  > So, ideally i could do something like this -
>  >
>  > response.url.split("?").first.should
>  > eql("http://test.host/admin/users/batch_saved")
>  >
>  >  I've been looking for documentation for methods for the response object, to
>  > get the url, but i can't find any in the api docs (i'm probably just looking
>  > in the wrong place).  I can see the url data in the object but it's private.
>
>  Well the RedirectTo matcher gets it using
>
>     response.redirect_url
>
>  I'd probably write the check as
>
>    response.should be_redirect
>    response.redirect_url.should
>  match(%r{^http://test.host/admin/users/batch_saved(\?|$)})

That seems reasonable given what is offered.

What do you guys think of a new matcher named redirect_with:

response.should redirect_with(:controller => 'admin/users', :action =>
'batch_saved')

This would let you express exactly what you want and only accept a
Hash and only match those present in the expectation, ignoring
anything else in the Hash.

I don't have the cycles to add this anytime soon, so if you like the
idea, feel free to submit a patch to the tracker.

Cheers,
David

>
>  --
>  Rick DeNatale
>
>  My blog on Ruby
>  http://talklikeaduck.denhaven2.com/
>
>
> _______________________________________________
>  rspec-users mailing list
>  rspec-users@...
>  http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: params are making my "should redirect_to" test fail - why??

by Rick DeNatale :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2/14/08, David Chelimsky <dchelimsky@...> wrote:
> On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale <rick.denatale@...> wrote:
>  > On 2/14/08, Max Williams <toastkid.williams@...> wrote:

>  >  >  I've been looking for documentation for methods for the response object, to
>  >  > get the url, but i can't find any in the api docs (i'm probably just looking
>  >  > in the wrong place).  I can see the url data in the object but it's private.
>  >
>  >  Well the RedirectTo matcher gets it using
>  >
>  >     response.redirect_url
>  >
>  >  I'd probably write the check as
>  >
>  >    response.should be_redirect
>  >    response.redirect_url.should
>  >  match(%r{^http://test.host/admin/users/batch_saved(\?|$)})
>
>
> That seems reasonable given what is offered.
>
>  What do you guys think of a new matcher named redirect_with:
>
>  response.should redirect_with(:controller => 'admin/users', :action =>
>  'batch_saved')
>
>  This would let you express exactly what you want and only accept a
>  Hash and only match those present in the expectation, ignoring
>  anything else in the Hash.
>
>  I don't have the cycles to add this anytime soon, so if you like the
>  idea, feel free to submit a patch to the tracker.

I'd be happy to do that, although I'm not entirely convinced that
redirect_with is the right name, not that I've got a better
alternative.

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: params are making my "should redirect_to" test fail - why??

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Feb 14, 2008 at 9:48 AM, Rick DeNatale <rick.denatale@...> wrote:

> On 2/14/08, David Chelimsky <dchelimsky@...> wrote:
>  > On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale <rick.denatale@...> wrote:
>  >  > On 2/14/08, Max Williams <toastkid.williams@...> wrote:
>
>
> >  >  >  I've been looking for documentation for methods for the response object, to
>  >  >  > get the url, but i can't find any in the api docs (i'm probably just looking
>  >  >  > in the wrong place).  I can see the url data in the object but it's private.
>  >  >
>  >  >  Well the RedirectTo matcher gets it using
>  >  >
>  >  >     response.redirect_url
>  >  >
>  >  >  I'd probably write the check as
>  >  >
>  >  >    response.should be_redirect
>  >  >    response.redirect_url.should
>  >  >  match(%r{^http://test.host/admin/users/batch_saved(\?|$)})
>  >
>  >
>  > That seems reasonable given what is offered.
>  >
>  >  What do you guys think of a new matcher named redirect_with:
>  >
>  >  response.should redirect_with(:controller => 'admin/users', :action =>
>  >  'batch_saved')
>  >
>  >  This would let you express exactly what you want and only accept a
>  >  Hash and only match those present in the expectation, ignoring
>  >  anything else in the Hash.
>  >
>  >  I don't have the cycles to add this anytime soon, so if you like the
>  >  idea, feel free to submit a patch to the tracker.
>
>  I'd be happy to do that, although I'm not entirely convinced that
>  redirect_with is the right name, not that I've got a better
>  alternative.

redirect_with_options?

How about something added to the existing call?

response.should redirect_to(:controller => 'foo', :action =>
'bar').ignoring_other_options

Or something like that?

>
>  --
>
>
> Rick DeNatale
>
>  My blog on Ruby
>  http://talklikeaduck.denhaven2.com/
>  _______________________________________________
>  rspec-users mailing list
>  rspec-users@...
>  http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: params are making my "should redirect_to" test fail - why??

by Rick DeNatale :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2/14/08, David Chelimsky <dchelimsky@...> wrote:

> On Thu, Feb 14, 2008 at 9:48 AM, Rick DeNatale <rick.denatale@...> wrote:
>  > On 2/14/08, David Chelimsky <dchelimsky@...> wrote:
>  >  > On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale <rick.denatale@...> wrote:
>  >  >  I don't have the cycles to add this anytime soon, so if you like the
>  >  >  idea, feel free to submit a patch to the tracker.
>  >
>  >  I'd be happy to do that, although I'm not entirely convinced that
>  >  redirect_with is the right name, not that I've got a better
>  >  alternative.
>
>
> redirect_with_options?

I think I like that.


>  How about something added to the existing call?
>
>  response.should redirect_to(:controller => 'foo', :action =>
>  'bar').ignoring_other_options

This seems too wordy.


--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: params are making my "should redirect_to" test fail - why??

by Max Williams :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm new to rspec (and coding in general) but would it break a lot of people's tests if redirect_to was changed to do this by default?  It's what i expected it to do, personally, that is to pass if the given :action and :controller match up.  If i pass a url string, and it's missing the params, then it seems fair that it should fail, but if for example i just specify a controller, and that controller is called (with any action) i'd expect it to pass as well.

Like i say i'm a newb with no idea of the impact of this to existing tests :)

On 14/02/2008, Rick DeNatale <rick.denatale@...> wrote:
On 2/14/08, David Chelimsky <dchelimsky@...> wrote:
> On Thu, Feb 14, 2008 at 9:48 AM, Rick DeNatale <rick.denatale@...> wrote:
>  > On 2/14/08, David Chelimsky <dchelimsky@...> wrote:
>  >  > On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale <rick.denatale@...> wrote:

>  >  >  I don't have the cycles to add this anytime soon, so if you like the
>  >  >  idea, feel free to submit a patch to the tracker.
>  >
>  >  I'd be happy to do that, although I'm not entirely convinced that
>  >  redirect_with is the right name, not that I've got a better
>  >  alternative.
>
>
> redirect_with_options?


I think I like that.



>  How about something added to the existing call?
>
>  response.should redirect_to(:controller => 'foo', :action =>
>  'bar').ignoring_other_options


This seems too wordy.



--

Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users


_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: params are making my "should redirect_to" test fail - why??

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Feb 14, 2008 at 10:16 AM, Max Williams
<toastkid.williams@...> wrote:

> I'm new to rspec (and coding in general) but would it break a lot of
> people's tests if redirect_to was changed to do this by default?  It's what
> i expected it to do, personally, that is to pass if the given :action and
> :controller match up.  If i pass a url string, and it's missing the params,
> then it seems fair that it should fail, but if for example i just specify a
> controller, and that controller is called (with any action) i'd expect it to
> pass as well.
>
> Like i say i'm a newb with no idea of the impact of this to existing tests
> :)

It is conceivable that existing examples could break, but the docs do
set out the same expectation that you have.

Can you file a bug at http://rspec.lighthouseapp.com so we can get it
in the queue?


> On 14/02/2008, Rick DeNatale <rick.denatale@...> wrote:
> > On 2/14/08, David Chelimsky <dchelimsky@...> wrote:
> > > On Thu, Feb 14, 2008 at 9:48 AM, Rick DeNatale <rick.denatale@...>
> wrote:
> > >  > On 2/14/08, David Chelimsky <dchelimsky@...> wrote:
> > >  >  > On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale
> <rick.denatale@...> wrote:
> >
> > >  >  >  I don't have the cycles to add this anytime soon, so if you like
> the
> > >  >  >  idea, feel free to submit a patch to the tracker.
> > >  >
> > >  >  I'd be happy to do that, although I'm not entirely convinced that
> > >  >  redirect_with is the right name, not that I've got a better
> > >  >  alternative.
> > >
> > >
> > > redirect_with_options?
> >
> >
> > I think I like that.
> >
> >
> >
> > >  How about something added to the existing call?
> > >
> > >  response.should redirect_to(:controller => 'foo', :action =>
> > >  'bar').ignoring_other_options
> >
> >
> > This seems too wordy.
> >
> >
> >
> > --
> >
> > Rick DeNatale
> >
> > My blog on Ruby
> > http://talklikeaduck.denhaven2.com/
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users@...
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
>
>
> _______________________________________________
>  rspec-users mailing list
>  rspec-users@...
>  http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: params are making my "should redirect_to" test fail - why??

by Rick DeNatale :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Feb 14, 2008 at 10:32 AM, David Chelimsky <dchelimsky@...> wrote:

> On Thu, Feb 14, 2008 at 10:16 AM, Max Williams
>
> <toastkid.williams@...> wrote:
>
> > I'm new to rspec (and coding in general) but would it break a lot of
>  > people's tests if redirect_to was changed to do this by default?  It's what
>  > i expected it to do, personally, that is to pass if the given :action and
>  > :controller match up.  If i pass a url string, and it's missing the params,
>  > then it seems fair that it should fail, but if for example i just specify a
>  > controller, and that controller is called (with any action) i'd expect it to
>  > pass as well.
>  >
>  > Like i say i'm a newb with no idea of the impact of this to existing tests
>  > :)
>
>  It is conceivable that existing examples could break, but the docs do
>  set out the same expectation that you have.
>
>  Can you file a bug at http://rspec.lighthouseapp.com so we can get it
>  in the queue?

I guess I'll hold off on the patch then.

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: params are making my "should redirect_to" test fail - why??

by Max Williams :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Done, thanks everyone.

On 14/02/2008, David Chelimsky <dchelimsky@...> wrote:
On Thu, Feb 14, 2008 at 10:16 AM, Max Williams

<toastkid.williams@...> wrote:

> I'm new to rspec (and coding in general) but would it break a lot of
> people's tests if redirect_to was changed to do this by default?  It's what
> i expected it to do, personally, that is to pass if the given :action and
> :controller match up.  If i pass a url string, and it's missing the params,
> then it seems fair that it should fail, but if for example i just specify a
> controller, and that controller is called (with any action) i'd expect it to
> pass as well.
>
> Like i say i'm a newb with no idea of the impact of this to existing tests
> :)


It is conceivable that existing examples could break, but the docs do
set out the same expectation that you have.

Can you file a bug at http://rspec.lighthouseapp.com so we can get it
in the queue?



> On 14/02/2008, Rick DeNatale <rick.denatale@...> wrote:
> > On 2/14/08, David Chelimsky <dchelimsky@...> wrote:
> > > On Thu, Feb 14, 2008 at 9:48 AM, Rick DeNatale <rick.denatale@...>
> wrote:
> > >  > On 2/14/08, David Chelimsky <dchelimsky@...> wrote:
> > >  >  > On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale
> <rick.denatale@...> wrote:
> >
> > >  >  >  I don't have the cycles to add this anytime soon, so if you like
> the
> > >  >  >  idea, feel free to submit a patch to the tracker.
> > >  >
> > >  >  I'd be happy to do that, although I'm not entirely convinced that
> > >  >  redirect_with is the right name, not that I've got a better
> > >  >  alternative.
> > >
> > >
> > > redirect_with_options?
> >
> >
> > I think I like that.
> >
> >
> >
> > >  How about something added to the existing call?
> > >
> > >  response.should redirect_to(:controller => 'foo', :action =>
> > >  'bar').ignoring_other_options
> >
> >
> > This seems too wordy.
> >
> >
> >
> > --
> >
> > Rick DeNatale
> >
> > My blog on Ruby
> > http://talklikeaduck.denhaven2.com/
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users@...
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
>
>
> _______________________________________________
>  rspec-users mailing list
>  rspec-users@...
>  http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users


_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users