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

时间:2014-01-22 11:51:27

标签: ruby-on-rails excel rspec spreadsheet

我用于生成document.xls报告此

gem'excel_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)>'

哪里可能是错误?

1 个答案:

答案 0 :(得分:0)

您应该仔细查看excel_rails gem中的this行。它会查找生成xls文件的模板,因此您只需要在spec文件中添加render_views方法,测试就应该通过。