On 2008-10-12, at 23:49, O. Frabjous-Dey wrote:
Hi Nick,
The :new action comes straight from script/generate rspec_scaffold:
def new
@group = Group.new
respond_to do |format|
format.html
end
end
I took out the XML rendering, but left in the respond_to block just
in case I wanted to add it or something else later.
And here's :create.
def create
@group = Group.new(params[:group])
respond_to do |format|
if @group.save
flash[:notice] = 'Group was successfully created.'
# Make this user an officer of the group
Membership.create(:user_id => session[:user_id], :group_id
=> @group.id, :rank => 'officer')
format.html { redirect_to(@group) }
else
format.html { render :action => "new" }
end
end
end
Thanks!
O.
Hi again, O. In your spec, you're stubbing Group#new and returning a
mock. As a result, the "create" action uses that mock when creating
the Membership object. I've never specced relationships, so I'm not
sure what to suggest. Hopefully someone else can give some advice.
Cheers,
Nick
BTW, that last email of yours was sent directly to me, rather than to
the mailing list. Let's keep all of the messages on the list.
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users