On 22/02/2009, at 3:34 PM, vo.x wrote:
Hello all,
Is there some best practice how to test Rails controller action which
is using send_file method? Could you help me please?
Vit
On 23/02/2009, at 2:43 AM, vo.x wrote:
Just to be clear, this is how the action looks:
def download
log = ActivityLog.find(params[:id])
if log
send_file log.path
else
flash[:notice] = _("Log file \"#{params[:id]}\" was not found.")
redirect_to :action => 'index'
end
end
Vit
Hi Vit. Just stub #send_file as normal. For example:
before :each do
controller.stub!(:send_file).and_return ...
end
it "should send the requested file" do
controller.should_receive(:send_file).with(...).and_return ...
do_get
end
Cheers,
Nick
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users