WhitewidowScanner / whitewidow

SQL Vulnerability Scanner
972 stars 235 forks source link

Tests/add rspec #38

Closed TylerRockwell closed 7 years ago

TylerRockwell commented 7 years ago

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?

Ekultek commented 7 years ago

This is a lot of stuff changed, you're going to need to give me a few days to test it

TylerRockwell commented 7 years ago

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.

Ekultek commented 7 years ago

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

Ekultek commented 7 years ago

I fixed it, remerging