[rspec-users] Failing Flash Spec

David Chelimsky dchelimsky at gmail.com
Mon May 17 23:01:00 EDT 2010

On Mon, May 17, 2010 at 9:32 PM, Kwang how Tan <lists at ruby-forum.com> wrote:
> Here are the failure messages, and the backtraces.
> Thx
> 1) SessionsController #create authenticate fail flash.now[:error] should
> be set to failure
>    Failure/Error: flash.now[:error].should == "Invalid username or
> password!"
>    expected: "Invalid username or password!",
>         got: nil (using ==)

I think the problem here is that the expectation is set on flash.now,
but that's not how flash.now works - views still just access flash
(not flash.now). Try this:

      it 'flash.now[:error] should be set to failure' do
        post :create
        flash[:error].should == "Invalid username or password!"
> 2) SessionsController #create authenticate successfully should redirect
>    Failure/Error:
> expects(:redirect_to_target_or_default).with(twikets_path)

And in this case the expects message is being sent to the example
group, not the controller. Try:



More information about the rspec-users mailing list