Last night I got the scraper to write an output.txt file which listed all the contents of words_by_selector. Today I want to make it write to JSON instead of plain text and I want to back it with some tests.
Updating our tests
Our current test for words_by_selector looks like this:
We’re going to need to break that sucker so it’ll produce something more like this:
And we update words_by_selector to look like this:
Our new test should pass. Feel free to flip one of the numbers in the expected_hash to 99 or something to see it fail.
Now let’s make sure the runner takes the content out of the crawler and writes it to a JSON file.
And in runner.rb…
And there we go. Our first decent output from the crawler :D -Rob