rspec/rspec-rails — Issue #491: can't test response if controller method sends e-mail
Author: cerdiogenes
Created: 2012-01-22 17:25:06+00:00
State: open

I write a test that make a post to one of my controllers. Inside the controller I send an e-mail with the default rails support (Class.method.deliver) and then redirect to a specific URL. When the test run I get the following error:

Failure/Error: response.should redirect_to(my_system_url)
Expected response to be a <:redirect>, but was <200>

I also can't make tests like flash[:error].should =~ /pattern/. In this case I get the following:

Failure/Error: flash[:error].should =~ /pattern/
expected: /pattern/
got: nil (using =~)

I use these kind of expectations all over the place. Only in this place, where I send e-mail, the test doesn't work.