-- Controller ----
   
def create
 
 @avatars = Avatar.find( :all,
                            :conditions => { :user_id => 0 }
                          )
   
    @avatars.concat( user.avatars )
 
end
 
 
--- spec ---
 
describe UserAvatarsController do

describe :create do
 
before(:each) do
 
@avatar = mock_model(Avatar)
@user = mock_model(User)
controller.stub!(:requires_user).and_return(@user)
Avatar.stub!(:find).and_return(@avatar)
User.stub(:avatar).and_return(@user)
Avatar.stub!(:concat).and_return(@user)
 
end
 
it "should create a new user avatar" do
Avatar.should_receive(:find).and_return(@avatar)
User.should_receive(:avatar).and_return(@user)
post :create
end 
end
 
end
 
I am getting the below error
 
--- Error ---
 
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.avatars
 
How should I spec this?
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to