[rspec-devel] [ rspec-Bugs-6059 ] Controller testing w/ Rails: response is not upated when same action is GETted multiple times within a specify block

noreply at rubyforge.org noreply at rubyforge.org
Sat Oct 7 21:54:25 EDT 2006


Bugs item #6059, was opened at 2006-10-08 11:54
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6059&group_id=797

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: David Lee (davidlee)
Assigned to: Nobody (None)
Summary: Controller testing w/ Rails: response is not upated when same action is GETted multiple times within a specify block

Initial Comment:
Controller testing with RSpec + Rails: response is not upated within a specification when same action is called multiple times within a specify block

using Rails 1.1.6 and RSpec 0.6.4

The response object is not being updated within a specify block if multiple responses are generated by GETting the same action. 

This was verified by checking the redirect_url reported.

This does not appear to be an issue unless the *same action* is called multiple times within a specify block, eg to test the effect of accessing an action with different permissions or parameters. Calling the action with different parameters did not appear to affect the problem.

example:

  specify "Index should redirect to welcome if already logged in" do

    # this will redirect to login as user is not logged in.
    # the presence of this line will break the test.
    get :index 

    request.session[:user] = 1 # subsequent gets will redirect to welcome
   
    # this will be ignored with regard to the response.redirect_url reported
    get :index 
    response.should_redirect

    # fails if first line is present:
    # says the redirect_url equals 'http://test.host/account/login'
    # which is a leftover from the first get :index
    response.redirect_url.should_equal 'http://test.host/account/welcome'
  end

breaking the two `get :index` calls out into separate specify blocks alleviates the problem.


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6059&group_id=797


More information about the rspec-devel mailing list