Search code examples
ruby-on-railsrubyrspecroo

Why response.body not readable with xlsx format


I want to add the RSpec test for our exporting file with the xlsx file but after getting the index of the end-point with xlsx format, my response.body is not readable and I can't check file contents

rspec:

it 'returns a successful 200 response for xlsx format' do
  get :index, format: :json

  expect(response).to be_successful
  expect(response.headers['Content-Type']).to eq('my_value'; charset=utf-8')
  expect(response.request.fullpath).to eq('end_poing_path.xlsx')
end

but when I want to check response.body I got bellow picture

response.body


Solution

  • I used caxlsx gem and it's can't read Excel files, so I had to install another gem (Roo or simple_xlsx_reader) for reading excel files, then I open response.body or file with simple_xlsx_reader gem

    enter image description here