Thanks Fred.

I actually did it like this in the end, I put this in test_helper

  # Add more helper methods to be used by all tests here...

  def login
    @request.env['HTTP_AUTHORIZATION'] = 'Basic ' + 
Base64::encode64("foo:bar")
  end

and then in the tests like this

  test "should destroy item" do
    login
    assert_difference('Item.count', -1) do
      delete :destroy, :id => items(:one).to_param
    end

    assert_redirected_to items_path
  end

  ##########################

  test "should not get index" do
    # don't login in this test.
    get :index
    assert_response :unauthorized
    assert_nil assigns(:items)
  end



-----


Would appreciate any comments on this approach.


-- 
Posted via http://www.ruby-forum.com/.

-- 
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 [email protected].
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.

Reply via email to