Skip to content

Instantly share code, notes, and snippets.

@t-oginogin
Created May 2, 2014 10:55
Show Gist options
  • Select an option

  • Save t-oginogin/11472251 to your computer and use it in GitHub Desktop.

Select an option

Save t-oginogin/11472251 to your computer and use it in GitHub Desktop.
Rails MiniTestでCSVファイルを返すControllerをテストしたい ref: http://qiita.com/t_oginogin/items/04018fd9eb9507e2bec8
def create_csv
<略>
respond_to do |format|
format.csv {
send_data records.to_csv, :type => 'text/csv', :filename => 'test.csv'
return
}
end
end
describe "create_csv" do
it "return csv file" do
get :create_csv
response.body.each_line |line| do
assert_match /\d,\d,\d/, line
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment