Testing with before_filter

Hi all
i’ve developed before_filter - http://gist.github.com/138659 and in
tests like
test “should get index” do
get :index
assert_response :success
assert_not_nil assigns(:articles)
end

i see
test_should_get_index(ArticlesControllerTest):
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.split
app/controllers/application_controller.rb:20:in set_locale' /test/functional/articles_controller_test.rb:5:intest_should_get_index’

When i’ve added
setup do
@request.headers[‘HTTP_ACCEPT_LANGUAGE’] = “en”
end

nothing changed :frowning: Could you tell me plz - whats wrong?

Rails 2.3.2, Ruby 1.8

I’ve solved this issue with
@request.env[‘HOST’] = “somesite.com
@request.env[‘HTTP_ACCEPT_LANGUAGE’] = “en”

Alexey Poimtsev wrote:

Hi all
i’ve developed before_filter - http://gist.github.com/138659 and in
tests like
test “should get index” do
get :index
assert_response :success
assert_not_nil assigns(:articles)
end

i see
test_should_get_index(ArticlesControllerTest):
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.split
app/controllers/application_controller.rb:20:in set_locale' /test/functional/articles_controller_test.rb:5:intest_should_get_index’

When i’ve added
setup do
@request.headers[‘HTTP_ACCEPT_LANGUAGE’] = “en”
end

nothing changed :frowning: Could you tell me plz - whats wrong?

Rails 2.3.2, Ruby 1.8

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