On Mon, Sep 22, 2008 at 9:07 AM, Carmine Moleti <[EMAIL PROTECTED]>wrote:
> > def create > authenticate_with_open_id(params[:identity_url], :required => [ > :nickname, :email ], :optional => :fullname) do |result, identity_url, > registration| > if result.successful? > @user = User.new > @user.identity_url = identity_url > @user.roles << Role.find_by_name('operator') > @user.user_type = 'operator' > assign_registration_attributes!(registration) > @user.save(false) > redirect_to users_path > else > redirect_to new_user_path > end > end > end > > How am I supposed to write a spec to test the code shown above? > The first thing I would do would be to refactor this code into the User model. The controller shouldn't be concerned with assigning the user_type, for example. The first test pass successfully while the second throws havocs on me. > It complains on the "@user.should_receive(:save..." part. > It also complained when I wrote > "User.should_receive(:new).and_return(@user)", so I changed > it to "User.stub!(:new)...". But I don't fully understand why I had to > do so. > Others may have more insight, but I would want to know what the specific complaints were. ///ark
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users