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/.
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
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[
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