Closed TylerRockwell closed 7 years ago
This is a lot of stuff changed, you're going to need to give me a few days to test it
No worries. There was a bit that needed to be added/changed to get it into a good testable state. Most of the non-testing code is the same as before, just moved into a new class (though some methods now take parameters instead of reading OPTIONS
directly).
On the bright side, once you review the tests, just running rspec
should help to give confidence that things aren't completely broken in the future.
This was reverted, the rspec
fails with this:
$ rspec
FF.......
Failures:
1) Whitewidow::Scanner usage_page displays usage info
Failure/Error: File.truncate('tmp/#sites.txt', 0)
Errno::ENOENT:
No such file or directory @ rb_file_s_truncate - tmp/#sites.txt
# ./spec/spec_helper.rb:19:in `truncate'
# ./spec/spec_helper.rb:19:in `block (2 levels) in <top (required)>'
2) Whitewidow::Scanner usage_page displays a reference to the README
Failure/Error: File.truncate('tmp/#sites.txt', 0)
Errno::ENOENT:
No such file or directory @ rb_file_s_truncate - tmp/#sites.txt
# ./spec/spec_helper.rb:19:in `truncate'
# ./spec/spec_helper.rb:19:in `block (2 levels) in <top (required)>'
Finished in 4.62 seconds (files took 10.19 seconds to load)
9 examples, 2 failures
Failed examples:
rspec ./spec/whitewidow/scanner_spec.rb:6 # Whitewidow::Scanner usage_page displays usage info
rspec ./spec/whitewidow/scanner_spec.rb:10 # Whitewidow::Scanner usage_page displays a reference to the README
Fix it and i'll merge it
I fixed it, remerging
Why?
As Whitewidow grows, the code will become harder to maintain and harder to manually test to ensure no new bugs have been introduced.
By adding tests, separating the code into classes with a single responsibility, and reducing coupling between said classes, changes will be easier and safer to make.
What Changed?
Extracted
Scanner
logic out to a separate module.lib/whitewidow/scanner.rb
whitewidow.rb
Introduced RSpec testing framework
Scanner
module that tests a good portion of the primary logicAdded Webmock and VCR to ensure tests are not doing live scans