On Sep 1, 3:26 pm, Stephen Eley wrote: > For what kind of test? The specific situation that started the question rolling around in my head was specing out a build method in a controller which creates an instance of a join model between two User instances. My setup includes AuthLogic and Machinist. I am using the suggested AuthLogic setup which has a current_user helper method in the app which returns the current user from the session. One of my main reasons for using a fixture replacement is because I can create a user object with Machinist and then set the user as logged in. To me this more closely models the structure of the app. But as someone new to rspec, I found it tricky to spec out the build method in the following controller code. Which leads me to believe I was using fixture replacements inappropriately and/or too often.
# follows_controller.rb class FollowsController < ApplicationController def create @follow = current_user.follows.build(:followed_id => params [:followed_id]) if @follow.save flash[:notice] = "Following created." redirect_to user_path(params[:followed_id]) else flash[:error] = "Unable to follow." redirect_to user_path(params[:followed_id]) end end end Initially, I wanted to write expectations such as: current_user.follows.should_receive(:build) But this is not possible since current_user is a method unavailable to the specs. At this point I realize this situation is much better served by stubbing and mocking the functions and models. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users