Forum: RSpec spec for not null

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mano a. (Guest)
on 2009-05-25 15:01
(Received via mailing list)
how should we check not null in rspec

         user_valid = @user.valid?
        password_credential_valid = @password.valid?


   I am getting the below error

    Mock 'User_1001' received unexpected message :valid? with (no args)

Diwa
David C. (Guest)
on 2009-05-25 17:31
(Received via mailing list)
On Mon, May 25, 2009 at 6:51 AM, Diwakar, ANGLER - EIT
<removed_email_address@domain.invalid> wrote:
> how should we check not null in rspec
>
>          user_valid = @user.valid?
>         password_credential_valid = @password.valid?
>
>
>    I am getting the below error
>
>     Mock 'User_1001' received unexpected message :valid? with (no args)

Assuming that @user is the same mock object that is causing the error,
you need to tell the @user that it should receive valid?:

  @user.should_receive(:valid?).and_return(true)

I'm not sure what this has to do with checking for not null.

- David
Mano a. (Guest)
on 2009-05-26 11:27
(Received via mailing list)
Thank you David it works
This topic is locked and can not be replied to.