Ruby on rails XLS报告不在Rails测试环境中生成

Ruby on rails XLS报告不在Rails测试环境中生成,ruby-on-rails,excel,rspec,spreadsheet,Ruby On Rails,Excel,Rspec,Spreadsheet,我正在使用生成document.xls此报告 gem“excel\u rails” 创业板“电子表格” 当我试图从我的浏览器中获取它时,它看起来一切都很好,但是当我试图从我的规范中访问它时,就像这样 get :document, { format: 'xls' } 1) ***Controller GET document.xls assigns project_test_exceptions Failure/Error: get :document, document_params Ac

我正在使用生成document.xls此报告

gem“excel\u rails” 创业板“电子表格”

当我试图从我的浏览器中获取它时,它看起来一切都很好,但是当我试图从我的规范中访问它时,就像这样

get :document, { format: 'xls' }
1) ***Controller GET document.xls assigns project_test_exceptions
 Failure/Error: get :document, document_params
 ActionView::Template::Error:
   ***/document.xls.rxls:1: syntax error, unexpected '.', expecting keyword_end
   ...t_buffer;;sio = StringIO.new; .write(sio); sio.string
   ...                               ^
 # ./app/***_controller.rb:56:in `block (2 levels) in document'
 # ./app/***_controller.rb:55:in `document'
 # ./spec/***_spec.rb:301:in `block (3 levels) in <top (required)>'
事情会是这样的

get :document, { format: 'xls' }
1) ***Controller GET document.xls assigns project_test_exceptions
 Failure/Error: get :document, document_params
 ActionView::Template::Error:
   ***/document.xls.rxls:1: syntax error, unexpected '.', expecting keyword_end
   ...t_buffer;;sio = StringIO.new; .write(sio); sio.string
   ...                               ^
 # ./app/***_controller.rb:56:in `block (2 levels) in document'
 # ./app/***_controller.rb:55:in `document'
 # ./spec/***_spec.rb:301:in `block (3 levels) in <top (required)>'
1)***Controller GET document.xls分配项目测试异常
失败/错误:获取:文档,文档参数
ActionView::模板::错误:
***/document.xls.rxls:1:语法错误,意外的“.”,应为关键字\u end
…t_缓冲区;;sio=StringIO.new。写入(sio);硅线
...                               ^
#./app/***\u controller.rb:56:in“文件中的块(2级)”中
#./app/***\u controller.rb:55:在“文档”中
#./spec/***spec.rb:301:in‘分块(3层)in’

哪里可能有错误?

您应该仔细查看
excel\u rails
gem中的行。它寻找一个模板来生成xls文件,所以您只需要向spec文件中添加一个方法,测试就会通过。

未找到解决方案,因此我使用“to_电子表格”gem()生成xls