hathitrust / hathifiles

Generation of Hathfiles
0 stars 0 forks source link

Use .rspec #47

Open moseshll opened 4 months ago

moseshll commented 4 months ago

Some specs rely on being run all at once so the constants defined in spec_helper.rb are available everywhere, but may not have the explicit require "spec_helper" line. The most concise thing to do is probably to add an .rspec with a --require spec_helper line. Alternatively we could just add the missing requires but why not just assume all the specs should have the helper available?

As reported:

### without spec_helper in spec/hathifile_history/records_spec.rb 

$ bundle exec rspec spec/hathifile_history/records_spec.rb
.........................E, [2024-05-07T15:20:38.146248 #423] ERROR -- : Can't get yyyymm from filename 'blah'. Aborting
..E, [2024-05-07T15:20:38.146871 #423] ERROR -- : Can't get yyyymm from filename 'blah'. Aborting
...

Finished in 0.01617 seconds (files took 0.72769 seconds to load)
30 examples, 0 failures

Coverage report generated for RSpec to /usr/src/app/coverage. 275 / 392 LOC (70.15%) covered.
Lcov style coverage report generated for RSpec to coverage/lcov.info
root@e1114083d61c:/usr/src/app# bundle exec rspec spec/hathifile_history/records_spec.rb

An error occurred while loading ./spec/hathifile_history/records_spec.rb.
Failure/Error: VALID_LINE = "#{TEST_HTID}\tdeny\tic\t#{TEST_RECID}\tother fields..."

NameError:
  uninitialized constant TEST_HTID
# ./spec/hathifile_history/records_spec.rb:7:in `<top (required)>'
No examples found.