While working on a fix for issue #222 I found that I needed to update the dummy search index in the tests. I thought that it would be good to improve the search tests so that they instead use the search.json file from building the example site in this repo.
This PR makes that change by refactoring the rebuild_site! RSpec helper out of the RSpec configuration, and adding it to the jasmine-gem helpers as well. This means that before the JavaScript tests are run, the example site will be built. We can then replace the dummy search index with a AJAX request to the existing JSON file.
Change to search results format
After doing this change I found that the tests were failing, because the dummy index was out-of-sync with the index produced by the production code. So this PR also changes the formatting of page HTML slightly, to add whitespace after heading tags, so that search results no longer have word collisions. This also means that headings in search results will no longer be followed by the first sentence of the section.
Before
After
This is an expired page
… This is an expired pageSee the banner on this page …
This is an expired page
… This is an expired page …
I feel that this change should still be made though, as having word collisions is pretty bad.
While working on a fix for issue #222 I found that I needed to update the dummy search index in the tests. I thought that it would be good to improve the search tests so that they instead use the
search.json
file from building the example site in this repo.This PR makes that change by refactoring the
rebuild_site!
RSpec helper out of the RSpec configuration, and adding it to thejasmine-gem
helpers as well. This means that before the JavaScript tests are run, the example site will be built. We can then replace the dummy search index with a AJAX request to the existing JSON file.Change to search results format
After doing this change I found that the tests were failing, because the dummy index was out-of-sync with the index produced by the production code. So this PR also changes the formatting of page HTML slightly, to add whitespace after heading tags, so that search results no longer have word collisions. This also means that headings in search results will no longer be followed by the first sentence of the section.
I feel that this change should still be made though, as having word collisions is pretty bad.