Testing errors

def test_create
num_articles = Article.count

post :create, :article => {}

assert_response :redirect
assert_redirected_to :action => 'list'

assert_equal num_articles + 1, Article.count

end

def test_edit
get :edit, :id => 1

assert_response :success
assert_template 'edit'

assert_not_nil assigns(:article)
assert assigns(:article).valid?

end

  1. Failure:
    test_create(ArticlesControllerTest) [test/functional/
    articles_controller_test.rb:99]:
    Expected response to be a redirect to http://test.host/articles/list
    but was a redirect to http://test.host/admin/login.

  2. Failure:
    test_edit(ArticlesControllerTest) [test/functional/
    articles_controller_test.rb:107]:
    Expected response to be a <:success>, but was <302>

how do i solve these errors?

thank you

This is happenening because of the before_filter :login_required, in
your controller. You will have to stub out the user authentication
methods in order for your tests to pass.

Sanjana D. wrote:

  1. Failure:
    test_create(ArticlesControllerTest) [test/functional/
    articles_controller_test.rb:99]:
    Expected response to be a redirect to http://test.host/articles/list
    but was a redirect to http://test.host/admin/login.

  2. Failure:
    test_edit(ArticlesControllerTest) [test/functional/
    articles_controller_test.rb:107]:
    Expected response to be a <:success>, but was <302>

how do i solve these errors?

thank you