Skip to content

Running Tests

LeePlace edited this page Apr 4, 2017 · 4 revisions

Rspec tests

To run the test suite, simply run:

rspec

or with verbose output:

rspec -f d

To view the coverage report, open

coverage/index.html

Rubocop

rubocop -D

Javascript Tests

Teaspoon/Jasmine/Istanbul Unit and Coverage tests

Teaspoon is used for Javascript testing and coverage. It runs Jasmine for unit and integration tests and Istanbul for test coverage.

First install Istanbul:

npm install -g istanbul

To run Teaspoon for unit tests, run:

bundle exec teaspoon

To include Istanbul coverage tests, run:

bundle exec teaspoon --coverage=default

To view interactive report of test coverage, open:

coverage/default/index.html 

JSHint Lint Tests

Trying to use this JShint gem, per its docs:
Add gem jshint to the Gemfile under group :development, :test

Run bundle to install, then run bundle exec rake jshint to run test. Currently this is running the linter then causing a rake error, which appears to be an ongoing issue with this gem.

Testing database entries

cd to the folder hubzone-data-etl/test/sql run sh run_sql_tests.sh --> all tests should come back passed. If not, then some data import is missing.

If you have a lot of tests failing for missing tables (like the qnmc tables prior to 2016) you will need to run the qnmc historical im
port.

  • Copy the contents of db/imports_all_qnmc_historic.csv into db/imports.csv and re-run rake hz:import. This will import all the
    legacy qnmc tables.
  • Revert db/imports.csv to its original state.
  • If you re-run your tests now, they should all be passing. These historical files do not appear on the map, but are needed for histor
    ical search and for the disaster areas calculations.

SQL Lint

For basic linting for syntax errors in ETL SQL files sqlint ./*/*.sql