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!

On 26 August 2010 06:28, Georgie P. [email protected]
wrote:

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.+”>

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

Colin

On 26 August 2010 21:12, Georgie P. [email protected]
wrote:

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

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:inrun’
/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:inrun’
/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:ineach’
/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:inrun_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:instart’
/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:inrun’
/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)

On Aug 26, 2010, at 4:12 PM, Georgie P. wrote:

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

To unsubscribe from this group, send email to [email protected]
.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
.

Rob B.
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/

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!

On Aug 26, 3:38 pm, Rob B. [email protected]

On 26 August 2010 21:29, Georgie P. [email protected]
wrote:

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

On Thu, Aug 26, 2010 at 3:45 PM, Georgie P.
[email protected] wrote:

I’m not sure what you mean by “see what’s on
the left side of a ‘+’.” because there is no ‘+’.

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.


Greg D.
destiney.com | gregdonald.com

On 26 August 2010 21:45, Georgie P. [email protected]
wrote:

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!

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs