Skip to content

Instantly share code, notes, and snippets.

@jasonroelofs
Created January 19, 2010 20:10
Show Gist options
  • Save jasonroelofs/281243 to your computer and use it in GitHub Desktop.
Save jasonroelofs/281243 to your computer and use it in GitHub Desktop.
##
# From: http://d.hatena.ne.jp/falkenhagen/20090702/1246503899
#
# Quick-n-dirty helper module method for testing the results of
# using #send_file in your controllers
##
module SendFileHelper
def file_body
output = StringIO.new
output.binmode
assert_nothing_raised do
@response.body.call(@response, output)
end
output.string
end
end
## And to use:
def test_send_file_is_good
get :action
assert_equals "File Body as String", file_body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment