everypolitician / scraper_test

Data-driven scraper tests for Scraped
0 stars 0 forks source link

Test failures can be hard to decipher #6

Open chrismytton opened 7 years ago

chrismytton commented 7 years ago

Problem

Test failures like this are hard to quickly comprehend, especially when they're wrapped in a terminal window.

$ bundle exec rake test                                                                                                                                                              1
Run options: --seed 8758

# Running:

F

Finished in 0.116234s, 8.6033 runs/s, 8.6033 assertions/s.

  1) Failure:
Scraper tests#test_0001_should contain the expected data [/Users/chris/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/scraper_test-a217cbd51d05/lib/scraper_test.rb:37]:
--- expected
+++ actual
@@ -1 +1 @@
-{:term=>"1", :name=>"Abril Martorell, Fernando", :family_names=>"Abril Martorell", :given_names=>"Fernando", :gender=>"male", :party=>"UCD", :source=>"http://www.congreso.es/portal/page/portal/Congreso/Congreso/Diputados/BusqForm?next_page=/wc/fichaDiputado&idDiputado=25&idLegislatura=1", :dob=>"", :faction=>"Grupo Parlamentario Centrista", :faction_id=>"GC", :start_date=>"1979-03-13", :end_date=>"1982-11-18", :email=>"", :twitter=>"", :facebook=>"", :constituency=>"Valencia", :photo=>"http://www.congreso.es/wc/htdocs/web/img/diputados/25_1.jpg"}
+{:term=>"1", :name=>"Abril Martorell, Fernando", :family_names=>"Abril Martorell", :given_names=>"Fernando", :gender=>"male", :party=>"UCD", :source=>"http://www.congreso.es/portal/page/portal/Congreso/Congreso/Diputados/BusqForm?next_page=/wc/fichaDiputado&idDiputado=25&idLegislatura=1", :dob=>"", :faction=>"Grupo Parlamentario Centrista", :faction_id=>"GC", :start_date=>"1979-03-13", :end_date=>"1982-11-18", :email=>"", :twitter=>"", :facebook=>"", :phone=>"", :fax=>"", :constituency=>"Valencia", :photo=>"http://www.congreso.es/wc/htdocs/web/img/diputados/25_1.jpg"}

1 runs, 1 assertions, 1 failures, 0 errors, 0 skips

Proposed solution

It would be good to print it more YAML-style, rather than as a big hash, then it could have diffs for just the lines that differ.