¿Cómo probar send_data en RSpec? O ... ¿para qué debería estar probando en este caso?

¿Cuál es la mejor manera de probar el siguiente código usando RSpec? ¿Y para qué debería estar probando? La acción de mostrar abre un archivo y lo transmite. Además, si la acción se basa en un archivo existente en algún lugar, ¿puedo probar eso?

<code>def show
  image_option = params[:image_option]
  respond_to do |format|
    format.js
    format.pdf {open_bmap_file("#{@bmap.bmap_pdf_file}", 'application/pdf', "#{@bmap.bmap_name}.pdf", "pdf", "pdf")}
    format.png {open_bmap_file("#{@bmap.bmap_png_file}", 'image/png', "#{@bmap.bmap_name}.png", "png", image_option)}
  end
end

private

def open_bmap_file(filename, application_type, send_filename, format, image_option = nil)
  filename = "app/assets/images/image_not_available_small.png" unless File.exist? filename
  path = Bmap.bmaps_pngs_path

case image_option
  when "image"
    filename = "#{@bmap.bmap_name}.png"
  when "large_thumbnail"
    filename = "#{@bmap.bmap_name}_large_thumb.png"
  when "thumbnail"
    filename = "#{@bmap.bmap_name}_thumb.png"
  when "pdf"
    filename = "#{@bmap.bmap_name}.pdf"
    path = Bmap.bmaps_pdfs_path
  else
    filename = "#{@bmap.bmap_name}.pdf"
    path = Bmap.bmaps_pdfs_path
end

begin
  File.open(path + filename, 'rb') do |f|
    send_data f.read, :disposition => image_option == "pdf" ? 'attachment' : 'inline', :type => application_type, :filename => send_filename
  end
rescue
  flash[:error] = 'File not found.'
  redirect_to root_url
end
</code>

Respuestas a la pregunta(2)

Su respuesta a la pregunta