mardi 10 juillet 2018

Rails Testing Contents of CSV Download

I have a project set up to download information from a page as a csv. I'm trying to write a test that ensures the contents of this csv matches what is shown on the site, but I am not sure how to access the contents of the CSV. Here's my current attempt:

 test "check_acquired_shares_contents" do       
           data = ["Label Amount Of Shares Share Price Total Price Occurred On From Shareholder Share Transaction Action Share Transaction Type",
                    "Initial 100.0 100.0 10000.0 2001-05-06 CREATE ESPP", "On Date 20.0 10.0 200.0 2012-05-06 Bill TRANSFER INDIVIDUAL",
                    "Label Amount Of Shares Share Price Total Price Occurred On To Shareholder Share Transaction Action Share Transaction Type",
                    "Individual_transfers 10.0 10.0 100.0 2010-05-06 Bill TRANSFER INDIVIDUAL"]
            visit admin_shareholder_path(id: 1)
            find('.action_item', :text => 'Acquired Shares CSV').click
            #binding.pry
            assert data == page.all('tr').map { |tr| tr.text }

    end

The data array is what the CSV is meant to contain. However, I think I am not checking the contents of the CSV, because the test always fails.

Anyone have ideas on how to check the CSV contents? Thank you!

Aucun commentaire:

Enregistrer un commentaire