Nil object error during integration test


#1

hello all,

I have a simple test case that load home page.
When I run test i got following error.

test_load_site_with_out_errors(UserScenariosTest)
[test/integration/user_scenarios_test.rb:18:in get_home_page' test/integration/user_scenarios_test.rb:7:intest_load_site_with_out_error
s’
F:/Aflatune_Community_Engine/aflatune/vendor/rails/activesupport/lib/active
_support/testing/setup_and_teardown.rb:60:in __send__' F:/Aflatune_Community_Engine/aflatune/vendor/rails/activesupport/lib/active _support/testing/setup_and_teardown.rb:60:inrun’
F:/Aflatune_Community_Engine/aflatune/vendor/rails/actionpack/lib/action_co
ntroller/integration.rb:597:in `run’]:
Expected response to be a <:success>, but was <500>
<“You have a nil object when you didn’t expect it!\nThe error occurred
while eva
luating nil.downcase”>

2 tests, 1 assertions, 1 failures, 0 errors


user_scenarios_test.rb

require “#{File.dirname(FILE)}/…/test_helper”
class UserScenariosTest < ActionController::IntegrationTest
fixtures :users

Load home page with out error

def test_load_site_with_out_errors
get_home_page
end

private
def get_home_page
get “/home/index”
assert_response :success
assert_template “index”
end

end

can anyone tell me about this error and solution.

Thanks,
Vikas.


#2

can anyone tell me about this error and solution.

It seems that somewhere in your code you are doing something.downcase,
and at that point something is nil:

<“You have a nil object when you didn’t expect it!\nThe error occurred
while evaluating nil.downcase”>

However, Rails questions are best directed to a Rails forum or mailing
list.

Regards,

Brian.