Re: [rspec-users] how to mock active record relationships

2009-10-21 Thread Christoph ----
Thanks guys, you really helped me a lot where to put my focus on. I will refactor my code to have it more easily being mocked, I thought about this at one point, but kept it for readability. Hope to get my specs up running soon. -- Posted via http://www.ruby-forum.com/.

Re: [rspec-users] how to mock active record relationships

2009-10-21 Thread Pat Maddox
user = mock('user') controller.stub(:current_user).and_return user friendships_proxy = mock('friendships proxy') user.stub(:friendships).and_return friendships_proxy friendship = mock('friendship') friendhips_proxy.stub(:build).and_return friendship Try to avoid chains like this. Makes the test s

Re: [rspec-users] how to mock active record relationships

2009-10-21 Thread Ashley Moran
On 21 Oct 2009, at 06:40, Christoph wrote: Hi I am new to Rspec and try to mock my controller that looks like def create @friendship = current_user.friendships.build(:friend_id => params[:friend_id]) if @friendship.save flash[:notice] = "Added friend." render :text => flash[

[rspec-users] how to mock active record relationships

2009-10-20 Thread Christoph ----
Hi I am new to Rspec and try to mock my controller that looks like def create @friendship = current_user.friendships.build(:friend_id => params[:friend_id]) if @friendship.save flash[:notice] = "Added friend." render :text => flash[:notice] else flash[:error] = "Erro