Ruby on rails Rspec对xls的响应

Ruby on rails Rspec对xls的响应,ruby-on-rails,testing,rspec,xls,Ruby On Rails,Testing,Rspec,Xls,我的控制器中有此方法: def index @hedge_fund_index_matrix = HedgeFundIndices.matrix @hedge_fund_index_headers = HedgeFundIndices.headers respond_to do |format| format.html {} format.xls { headers["Content-Disposition"] = "attachm

我的控制器中有此方法:

def index
    @hedge_fund_index_matrix = HedgeFundIndices.matrix
    @hedge_fund_index_headers = HedgeFundIndices.headers
    respond_to do |format|
      format.html {}
      format.xls {
        headers["Content-Disposition"] = "attachment; filename=\"HedgeFundIndices_#{DateTime.now.strftime('%Y%m%d_%H%M')}\""
      }
    end
end
而且,我需要测试
响应

it "should respond with javascript" do
    get :index, {:id => @return_value}
    expect(.....).to (....)
end

您的测试应该如下所示:

it "should respond with javascript" do
    get :index, {:id => @return_value}, format: :xls
    expect(response).to be_success
end