how do you test csv file content in Rails? -
i'm writing simple canadapost price shipping api, prices given in pdf document in table format (see page 3 of https://www.canadapost.ca/tools/pg/prices/sbparcels-e.pdf).
the data extracted csv files , imported database (table prices has columns weight, rate_code , date). model , controller simple: take weight, rate_code , date , query prices table.
i'm trying create suite of tests tests existence , correctness of every single price in chart. has generic , reusable because data changes every year.
i thought of ideas:
1) read same csv files used import data database , create single rspec example loops around rows , columns , tests returned price.
2) convert csv files fixtures prices controller , test each fixture.
i'm having hard time categorizing these tests. not unit tests, functional/feature tests? sound more integration tests, i'm not sure if rails differentiates functional tests integration tests.
maybe answer obvious , i'm not seeing it.
program testing can effective way show presence of bugs, hopelessly inadequate showing absence (edsger wybe dijkstra)
first of all, think should assume csv parser did job correctly.
once did this, output csv file , put in specs (fixtures
, require
, load
), test output 1 see.
if correct every single line of csv file (i'm assuming it's big 1 given in link), conclude code works. wouldn't bother testing every year, unless make feel secure code.
you might anomaly afterwards, unfortunalely specs cannot detect that. can ensure works great year's data.
Comments
Post a Comment