我想确保我的CSV下载包含正确的列.当我使用RSpec测试CSV下载时,无法访问文件内容.如何访问CSV文件的内容?
require 'spec_helper' include Devise::TestHelpers describe Admin::ApplicationsController do before(:each) do @application = FactoryGirl.create :application @user = FactoryGirl.create( :admin_user ) sign_in @user end it "downloads a csv" it "gives us only the columns we want" do get :index,format: :csv p response.body p response.headers end end
测试的输出:
# This is the output in the terminal # "" # {"Content-Type"=>"text/csv; charset=utf-8","Content-Disposition"=>"attachment; filename=\"applications-2013-12-17.csv\""}