Problem with consecutive GET requests in integration test

2 views
Skip to first unread message

Georgie Porgie

unread,
Aug 26, 2010, 1:28:57 AM8/26/10
to Ruby on Rails: Talk
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!

clanlaw

unread,
Aug 26, 2010, 6:34:07 AM8/26/10
to rubyonra...@googlegroups.com
On 26 August 2010 06:28, Georgie Porgie <georgemi...@gmail.com> wrote:
> 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.+">
>

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

Colin

Georgie Porgie

unread,
Aug 26, 2010, 4:12:41 PM8/26/10
to Ruby on Rails: Talk
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)

Colin Law

unread,
Aug 26, 2010, 4:25:41 PM8/26/10
to rubyonra...@googlegroups.com
On 26 August 2010 21:12, Georgie Porgie <georgemi...@gmail.com> 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

> --
> 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 rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

Georgie Porgie

unread,
Aug 26, 2010, 4:29:26 PM8/26/10
to Ruby on Rails: Talk
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.

On Aug 26, 3:25 pm, Colin Law <clan...@googlemail.com> wrote:

Rob Biedenharn

unread,
Aug 26, 2010, 4:38:11 PM8/26/10
to rubyonra...@googlegroups.com

On Aug 26, 2010, at 4:12 PM, Georgie Porgie 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

>
> 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-
> ta...@googlegroups.com.


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

Rob Biedenharn
R...@AgileConsultingLLC.com http://AgileConsultingLLC.com/
r...@GaslightSoftware.com http://GaslightSoftware.com/

Georgie Porgie

unread,
Aug 26, 2010, 4:45:30 PM8/26/10
to Ruby on Rails: Talk
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 Biedenharn <R...@AgileConsultingLLC.com>
wrote:
> On Aug 26, 2010, at 4:12 PM, Georgie Porgie 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
>
>
>
> > 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-
> > ta...@googlegroups.com.
> > To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com
> > .
> > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en

Colin Law

unread,
Aug 26, 2010, 4:40:55 PM8/26/10
to rubyonra...@googlegroups.com
On 26 August 2010 21:29, Georgie Porgie <georgemi...@gmail.com> 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

Greg Donald

unread,
Aug 26, 2010, 4:55:44 PM8/26/10
to rubyonra...@googlegroups.com
On Thu, Aug 26, 2010 at 3:45 PM, Georgie Porgie
<georgemi...@gmail.com> 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 Donald
destiney.com | gregdonald.com

Colin Law

unread,
Aug 26, 2010, 5:10:57 PM8/26/10
to rubyonra...@googlegroups.com
On 26 August 2010 21:45, Georgie Porgie <georgemi...@gmail.com> 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

> To post to this group, send email to rubyonra...@googlegroups.com.

Georgie Porgie

unread,
Aug 30, 2010, 11:28:48 AM8/30/10
to Ruby on Rails: Talk
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!

On Aug 26, 4:10 pm, Colin Law <clan...@googlemail.com> wrote:
Reply all
Reply to author
Forward
0 new messages