Hey, May be it is just too deep night over here and I''m missing something though I got this failure on {{{response.should_not redirect_to}}}: ''QueuesController should allow authenticated user to access ''show'''' FAILED Matcher does not support should_not. See Spec::Matchers for more information about matchers. Also I''ve found this in rspec_on_rails sources: # response.should_not redirect_to(url) # response.should_not redirect_to(:action => action_name) # response.should_not redirect_to(:controller => controller_name, :action => action_name) So, am I really missing something important? I''ve added negative_failure_message to RedirectTo matcher and it seems to function just fine (though as I''ve stated, it''s quite late over here, so I could be wrong) class Spec::Rails::Matchers::RedirectTo def negative_failure_message return %Q{expected to not to be redirected to # {@expected.inspect}, but actually was redirected there} if @redirected end end Any ideas?
On 7/26/07, Yurii Rashkovskii <yrashk at gmail.com> wrote:> Hey, > > May be it is just too deep night over here and I''m missing something > though I got this failure on {{{response.should_not redirect_to}}}: > > ''QueuesController should allow authenticated user to access ''show'''' > FAILED > Matcher does not support should_not. > See Spec::Matchers for more information > about matchers. > > Also I''ve found this in rspec_on_rails sources: > > # response.should_not redirect_to(url) > # response.should_not redirect_to(:action => action_name) > # response.should_not redirect_to(:controller => > controller_name, :action => action_name) > > > So, am I really missing something important? > > I''ve added negative_failure_message to RedirectTo matcher and it > seems to function just fine (though as I''ve stated, it''s quite late > over here, so I could be wrong) > > class Spec::Rails::Matchers::RedirectTo > def negative_failure_message > return %Q{expected to not to be redirected to # > {@expected.inspect}, but actually was redirected there} if @redirected > end > end > > Any ideas?Sorry - the docs are inconsistent with the code - I intended to NOT allow "should_not redirect_to" because it seemed sort of silly to me. I would think you either want it to redirect somewhere known or expect something other than a redirect. WDYT? David
On Jul 27, 2007, at 3:26 AM, David Chelimsky wrote:> On 7/26/07, Yurii Rashkovskii <yrashk at gmail.com> wrote: >> Hey, >> >> May be it is just too deep night over here and I''m missing something >> though I got this failure on {{{response.should_not redirect_to}}}: >> >> ''QueuesController should allow authenticated user to access ''show'''' >> FAILED >> Matcher does not support should_not. >> See Spec::Matchers for more information >> about matchers....>> >> class Spec::Rails::Matchers::RedirectTo >> def negative_failure_message >> return %Q{expected to not to be redirected to # >> {@expected.inspect}, but actually was redirected there} if >> @redirected >> end >> end >> >> Any ideas? > > Sorry - the docs are inconsistent with the code - I intended to NOT > allow "should_not redirect_to" because it seemed sort of silly to me. > I would think you either want it to redirect somewhere known or expect > something other than a redirect. WDYT?Here is an extract from my source code it "should allow authenticated user to access ''#{action}''" do @user = mock_user_authentication(:id => 1, :identity_url => "http://openid.server/yrashk", :queues => []) get action, params assigns[:current_user].should == @user flash[:error].should be_nil response.should_not redirect_to(login_url) end Depending on action, it is either successful response or response that redirects somewhere (but not to login, since user is "proven" to be authenticated). In this example, I really don''t want to care, whether it was successful response or redirection to somewhere, until it is not a redirection to login URL. Stupid enough? Yurii.
On 7/26/07, Yurii Rashkovskii <yrashk at gmail.com> wrote:> > On Jul 27, 2007, at 3:26 AM, David Chelimsky wrote: > > > On 7/26/07, Yurii Rashkovskii <yrashk at gmail.com> wrote: > >> Hey, > >> > >> May be it is just too deep night over here and I''m missing something > >> though I got this failure on {{{response.should_not redirect_to}}}: > >> > >> ''QueuesController should allow authenticated user to access ''show'''' > >> FAILED > >> Matcher does not support should_not. > >> See Spec::Matchers for more information > >> about matchers. > > ... > > >> > >> class Spec::Rails::Matchers::RedirectTo > >> def negative_failure_message > >> return %Q{expected to not to be redirected to # > >> {@expected.inspect}, but actually was redirected there} if > >> @redirected > >> end > >> end > >> > >> Any ideas? > > > > Sorry - the docs are inconsistent with the code - I intended to NOT > > allow "should_not redirect_to" because it seemed sort of silly to me. > > I would think you either want it to redirect somewhere known or expect > > something other than a redirect. WDYT? > > Here is an extract from my source code > > it "should allow authenticated user to access ''#{action}''" do > @user = mock_user_authentication(:id => 1, :identity_url => > "http://openid.server/yrashk", :queues => []) > get action, params > assigns[:current_user].should == @user > flash[:error].should be_nil > response.should_not redirect_to(login_url) > end > > Depending on action, it is either successful response or response > that redirects somewhere (but not to login, since user is "proven" to > be authenticated). In this example, I really don''t want to care, > whether it was successful response or redirection to somewhere, until > it is not a redirection to login URL. > > Stupid enough?That''s not a fair question. Wanna submit a patch?> > Yurii. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David,>> >> Here is an extract from my source code >> >> it "should allow authenticated user to access ''#{action}''" do >> @user = mock_user_authentication(:id => 1, :identity_url => >> "http://openid.server/yrashk", :queues => []) >> get action, params >> assigns[:current_user].should == @user >> flash[:error].should be_nil >> response.should_not redirect_to(login_url) >> end >> >> Depending on action, it is either successful response or response >> that redirects somewhere (but not to login, since user is "proven" to >> be authenticated). In this example, I really don''t want to care, >> whether it was successful response or redirection to somewhere, until >> it is not a redirection to login URL. >> >> Stupid enough? > > That''s not a fair question. > > Wanna submit a patch? >With please ? the code was above, once I will understand where should I put a spec for it. I got some misunderstanding there (probably the night is reason :) Yurii.
On 7/26/07, Yurii Rashkovskii <yrashk at gmail.com> wrote:> David, > > >> > >> Here is an extract from my source code > >> > >> it "should allow authenticated user to access ''#{action}''" do > >> @user = mock_user_authentication(:id => 1, :identity_url => > >> "http://openid.server/yrashk", :queues => []) > >> get action, params > >> assigns[:current_user].should == @user > >> flash[:error].should be_nil > >> response.should_not redirect_to(login_url) > >> end > >> > >> Depending on action, it is either successful response or response > >> that redirects somewhere (but not to login, since user is "proven" to > >> be authenticated). In this example, I really don''t want to care, > >> whether it was successful response or redirection to somewhere, until > >> it is not a redirection to login URL. > >> > >> Stupid enough? > > > > That''s not a fair question. > > > > Wanna submit a patch? > > > > With please ? the code was above, once I will understand where should > I put a spec for it.rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb Cheers, David> I got some misunderstanding there (probably the > night is reason :) > > Yurii. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David,>>>> Depending on action, it is either successful response or response >>>> that redirects somewhere (but not to login, since user is >>>> "proven" to >>>> be authenticated). In this example, I really don''t want to care, >>>> whether it was successful response or redirection to somewhere, >>>> until >>>> it is not a redirection to login URL. >>>> >>>> Stupid enough? >>> >>> That''s not a fair question. >>> >>> Wanna submit a patch? >>> >> >> With please ? the code was above, once I will understand where should >> I put a spec for it. > > rspec_on_rails/spec/rails/matchers/redirect_to_spec.rbThat wasn''t an issue, I''d rather was thinking where to place it within this file. Anyway, patch is submitted. Thank you, Yurii.