ruby on rails - RSpec fails because actual redirect has a flash message -


thingscontroller:

...

respond_to |format|   format.html {redirect_to(:action => "new", :notice => "its thing!")}  # suspect... end 

when test code

  "should redirect /employees/new success notice"     post :create, :employee => factory.build(:employee).attributes     response.should redirect_to(:action => "new")     flash[:notice].should_not be_nil   end 

the test fails because not expect actual redirection have notice.

any suggestions?

yes, have suggestion: test different things on different lines.

response.should redirect_to(new_thing_path) flash[:notice].should eql("its thing!") 

this way, if redirect_to fails fail on line, , if flash[:notice] broken fail on line.

additionally, test should work.


Comments