Created
January 19, 2010 20:10
-
-
Save jasonroelofs/281243 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# 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