Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the fixtures #6

Open
chancancode opened this issue Mar 4, 2015 · 1 comment
Open

Improve the fixtures #6

chancancode opened this issue Mar 4, 2015 · 1 comment

Comments

@chancancode
Copy link
Owner

Let me explain the idea:

The app needs to fetch markup from the HN server and parse them into JSON. In order to prevent regressions in the parser, I have downloaded a bunch of HTML pages and put them in /tests/fixtures and froze the JSON output in there. So everytime I make changes to the parser, I can run the tests again and see the diff and decide if it's legit or not.

There's a in-repo add-on for making these fixtures available to the tests.

The HTML fixtures serves another purpose – there's a pretender server in /tests/helpers that serves these things to the integration tests. I hacked in an offline development mode (OFFLINE=1 ember server) which runs the dev server with the pretender thing enabled, so you can work on this without wifi.

I think these ideas are pretty great, but the implementations, not so much.

Problems:

  1. To make the fixtures available to the tests, I wrote this "fixture-packer" add-on (in lib). It was one of my first broccoli/add-on thing so the implementation is probably terrible. I also wrote a lot of features that I thought was cool but never used (import specificFixture from 'some/deeply/nested/thing' instead of justimport fixtures from 'all_the_things` and access it normally). I am pretty sure reading fixture files of some sort is a pretty common need, so we should either find something that already does this, or if that doesn't exists then improve/simplify/refactor the thing in there and extract it into a real add-on.
  2. The fixtures are huge! I think I am storing way too many of them (first 5 listing/index pages of each category/filter, then the individual item pages for the first 10 stories in each). They take up a lot of space too. And they make the repo size pretty big, because old fixtures stays in the git history too. (I think I nuked all of them at some point and re-downloaded them from HN, but the old ones are still stuck in the git history hell somewhere.)
  3. The process of updating the JSON fixtures is mega HAX. I'd empty out the JSON fixture files, run the tests (which would be failing of course) and extract actual result from the qunit reporter :P I guess what I really want is to be able to run the "extractors" as a standalone script, so after I downloaded new HTML fixtures, I can generate the JSON fixtures by run_that_extractor_somehow html_fixture.html > json_fixture.json.
@chancancode
Copy link
Owner Author

..opening this to see if anyone wants to teach me how to do these things properly, or better yet, doing it for me :trollface:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant