On Friday, December 26, 2014 03:29:53 PM Myron Marston wrote:
> On Thursday, December 25, 2014 12:21:06 PM UTC-8, Arup Rakshit wrote:
> > Hi,
> > 
> > Here is my route :-
> > 
> >   post '/export' do
> >   
> >     gist = List.new(Task.all).to_gist
> >     redirect gist['html_url']
> >   
> >   end
> > 
> > and the spec :-
> > 
> >     describe "/export" do
> >     
> >       let(:gist) { double('Gist') }
> >       let(:url) { "http://example.org/gist"; }
> >       
> >       it 'exports as a gist' do
> >       
> >         allow_any_instance_of(List).to receive(:to_gist) { gist }
> >         allow(gist).to receive(:[]).with('html_url').and_return(url)
> >         post "/export"
> >         expect(last_response).to be_redirect
> >         follow_redirect!
> >         expect(last_request.url).to eq(url)
> >       
> >       end
> >     
> >     end
> 
> What makes you think `follow_redirect!` isn't working?  It looks to me like
> it is following the redirect, making a new request, and then your view hits
> an exception when rendering the response for the 2nd response.  Without
> seeing your code, my best guess is that there's either a bug in your
> sinatra route or view (causing the the `id` message to be sent to a `nil`
> object in your view) or your sinatra is assuming some additional state that
> has not been setup in your test (e.g. the existence of some records in the
> database, or the user being logged in, etc).
> 
> Regardless, `follow_redirect!` is not part of RSpec.  It's part of
> rack-test, and any questions about it should be directed to the rack-test
> maintainers.
> 
> HTH,
> Myron

Myron,

Thanks for the reply. I'll pass it to the Rack-test list. But I thought, 
follow_redirect! should follow the url that gist['html_url'] is returning, but 
that's not happening. Actually it works in UI. But test is failing due to 
incorrect redirection.

-- 
================
Regards,
Arup Rakshit
================
Debugging is twice as hard as writing the code in the first place. Therefore, 
if you write the code as cleverly as possible, you are, by definition, not 
smart enough to debug it.

--Brian Kernighan

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/1521654.PXavyWLe7P%40linux-wzza.site.
For more options, visit https://groups.google.com/d/optout.

Reply via email to