Jul
15th
Sun
15th
Scaffolded code slips through rcov
The ‘else’ part of this scaffolded code is not covered by the generated controller spec.
# POST /orders
# POST /orders.xml
def create
@order = Order.new(params[:order])
respond_to do |format|
if @order.save
flash[:notice] = 'Order was successfully created.'
format.html { redirect_to(@order) }
format.xml { render :xml => @order, :status => :created, :location => @order }
else
format.html { render :action => "new" }
format.xml { render :xml => @order.errors, :status => :unprocessable_entity }
end
end
end
Added an extra example to get it to 100%
it "should save the new order" do
@order.should_receive(:save)
do_post
response.should render_template('new')
end