Joel Reymont
2006-Jun-29 21:57 UTC
[Rails] @response.body accumulating in functional tests?
I have two functional tests for my user controller: def test_bad_registration post :register, :email => "tester1@foo.com" assert_response :success assert_not_nil @response.body =~ /^\<error/ assert_nil assigns[''user''] end def test_good_registration @response.body = nil post :register, :username => "tester", :name => "Tester", :password => "test", :email => "tester@foo.com" assert_not_nil assigns[''user''] assert_response :success breakpoint puts "match: #{@response.body =~ /^\<user/}" puts "body: #{@response.body}" end I render xml from each like this "render :xml => ...". The first test goes through but the second one shows both the output of the first and second test in @response.body (below). It does not happen when the first test is commented out. <error> <message>Validation failed: Name can''t be blank, Username can''t be blank, Password can''t be blank</message> </error> <user> <userid>31</userid> <name>Tester</name> <username>tester</username> </user> Am I doing something wrong? Is there a better way to check rendered XML? Thanks, Joel -- http://wagerlabs.com/