I\'m trying to test a controller and I got this error. I understand the error, but don\'t know how to fix it.
test: on CREATE to :user with completely invali
In response to the question:
Why doesn't this work:
setup { post :create, { :user => { :email => 'invalid@abc' } },
{ 'referer' => '/sessions/new' } }
It doesn't work because the Rails doc you linked to documents a different class than the one you're probably using.
You linked to ActionController::Integration:Session. I'm guessing that you're writing a functional test (if you're using Test::Unit) or a controller test (if you're using Rspec). Either way, you're probably using ActionController::TestCase or a subclass thereof. Which, in turn, includes the module ActionController::TestProcess.
ActionController::TestProcess provides a get method with different parameters than the get method provided by ActionController::Integration:Session. (Annoying, eh?) The method signature is this:
def get(action, parameters = nil, session = nil, flash = nil)
Sadly, there is no headers parameter. But at least setting @request.env['HTTP_REFERER'] works.