[rspec-users] "warning: object#id will be deprecated" with mocks

aslak hellesoy aslak.hellesoy at gmail.com
Sat Feb 17 21:40:40 EST 2007


On 2/17/07, David Green <justnothing at tiscali.co.uk> wrote:
>
> hi all
>
> I have the following code in a spec:
>
>   @user = mock("user")
>   User.stub!(:authenticate).and_return(@user)
>   @user.should_receive(:id).once.and_return(99)
>   post :login, {:username => 'username', :password => 'password'}
>   session[:user_id].should == 99
>
> it works as expected but I get the following warning when I run the spec:
>  warning: object#id will be deprecated; use Object#object_id instead
>
> I'm new to testing with mocks, am I using them correctly and does anyone
> know how to disable the warning?
>

I'm assuming you are using RSpec with Rails (as opposed to a non-Rails
codebase). Try the latest RSpec on Rails release's mock_model method -
it stubs out default ActiveRecord methods like #id, #to_param in order
to make stubbing/mocking easier with ActiveRecord.

Aslak

> thanks
> --
> View this message in context: http://www.nabble.com/%22warning%3A-object-id-will-be-deprecated%22-with-mocks-tf3246300.html#a9024353
> Sent from the rspec-users mailing list archive at Nabble.com.
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list