I’m using Hpricot parser to scrape web pages. I saved two of these
pages for a test in lack of a better way, I put the html files in the
fixtures like this:
dl_found_tickets:
html: “<%= File.read( ‘test/fixtures/html/
search_dl_found_tickets.html’ ).gsub(’”’, ‘"’) %>"
[…]
Even though the crawl class works fine, the test fails, so it’s got to
be something wrong with the fixture. I a test that compares the html
string loaded from the fixture and the one loaded from the fixture and
they’re not the same. From what I can tell, it’s only whitespace
difference, from some end-of-line conversions, I guees.
This test fails:
def test_html_fixtures
assert_equal File.read( ‘test/fixtures/html/
search_plate_found_ticket.html’ ).slice(0, 250), crawls
(:dl_found_tickets).html.slice(0, 250)
end
- Failure:
test_html_fixtures(CrawlTest)
[test/unit/crawl_test.rb:16:intest_html_fixtures' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/testing/setup_and_teardown.rb:60:in
send’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/testing/setup_and_teardown.rb:60:in `run’]:
<"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r
\n\r\n\r\n\r\n\r\n\r\n<link rel=“stylesheet” type=“text/
css” h"> expected but was
<" \n\n\n\n\n\n\n\n