On 2/17/07, David Green <
justnothing@...> 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
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users