Problem with consecutive GET requests in integration test

class UserStoriesTest < ActionController::IntegrationTest
  test "some test" do
    get "/"
    assert_response :success
    get "/"
    assert_response :success
  end
end

When I run the code above the first assertion passes. However, the
second assertion fails because the response is a 500. To be more
specific I get this error:

Expected response to be a <:success>, but was <500>
<"You have a nil object when you didn't expect it!
   You might have expected an instance of Array.
   The error occurred while evaluating nil.+">

Anyone have an explanation? I want to to test some going to the
homepage and then clicking on a link to the login page which is why I
am calling consecutive GET requests. Help me if I am going about it
the wrong way.

Thanks in advance!

Have a look in test.log, there should be more information about the
error there, including where the error occurred.

Colin

Well this is all I get and i can't really make anything out of it:

NoMethodError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.+):
  /test/integration/user_stories_test.rb:12:in `some_test'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit/testsuite.rb:34:in `run'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit/testsuite.rb:33:in `each'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit/testsuite.rb:33:in `run'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit/testsuite.rb:34:in `run'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit/testsuite.rb:33:in `each'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit/testsuite.rb:33:in `run'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit/ui/testrunnermediator.rb:46:in `run_suite'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit/ui/console/testrunner.rb:67:in `start_mediator'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit/ui/console/testrunner.rb:41:in `start'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit/ui/testrunnerutilities.rb:29:in `run'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit/autorunner.rb:216:in `run'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit/autorunner.rb:12:in `run'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/test/unit.rb:278
  rake (0.8.7) lib/rake/rake_test_loader.rb:5

Rendered rescues/_trace (36.6ms)
Rendered rescues/_request_and_response (1.3ms)
Rendering rescues/layout (internal_server_error)

Well this is all I get and i can't really make anything out of it:

NoMethodError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.+):
/test/integration/user_stories_test.rb:12:in `some_test'

Which is that line? The code you showed only had 8 lines.

Colin

It's line #6. Sorry I cut out some comments and stuff so as to not
clutter the post. The response is a 500 and the assertion is failing
on like number 6 because it is expecting a 200. I'm just trying to
figure out why it's a 500.

Well this is all I get and i can't really make anything out of it:

NoMethodError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.+):
/test/integration/user_stories_test.rb:12:in `some_test'

You'd need to at least look at what's on that line and see what's on the left side of a '+'. THAT object is probably nil (and the whiny nils of Rails is looking for something that responds to + and offers Array as one possibility).

-Rob

Rendered rescues/_trace (36.6ms)
Rendered rescues/_request_and_response (1.3ms)
Rendering rescues/layout (internal_server_error)

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Rob Biedenharn
Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/
rab@GaslightSoftware.com http://GaslightSoftware.com/

It's line #6. Sorry I cut out some comments and stuff so as to not
clutter the post. The response is a 500 and the assertion is failing
on like number 6 because it is expecting a 200. I'm just trying to
figure out why it's a 500.

The error in the trace is showing as line 12, are you saying that is
the assert line? Could you post the whole file please just to keep me
happy.

Could you post the log showing the first half of the test also (the
get that works).

Please don't top post, it makes it difficult to follow the thread. Thanks.

Colin

I'm not sure what you mean by "see what's on
the left side of a '+'." because there is no '+'.

Just out of curiosity, can someone run this test on their app? I've
found that the same error happens even on a simple app that has a root
url available.

btw, I'm using rails 2.3.8 and ruby 1.8.7

Thanks!

Your error log says otherwise:

"The error occurred while evaluating nil.+"

That means you tried to do addition with a nil, and that doesn't work
since nil doesn't support the '+' method.

I'm not sure what you mean by "see what's on
the left side of a '+'." because there is no '+'.

Just out of curiosity, can someone run this test on their app? I've
found that the same error happens even on a simple app that has a root
url available.

It works ok for me on rails 2.3.2.

Colin

So I investigated further and it seems to be a facebooker problem with
session management. When I find the root problem, I'll post what it is
and what I did to fix it. Thanks for the help!