jsonapi-suite / jsonapi_compliable

MIT License
20 stars 35 forks source link

1.0: Major spec refactor #107

Closed richmolj closed 6 years ago

richmolj commented 6 years ago

So we have three groups of tests:

The last two groups can seem conceptually fuzzy and there is definitely some overlap. The "functional" tests still used ActiveRecord, for instance (this was mostly for convenience at the time).

This refactors all tests in the first two groups to use POROs (defined in spec/fixtures/poro.rb), and to use the same domain (employee directory) across all tests. The only non-ED tests are in spec/integration/rails/*, which I'm avoiding touching now because they are the best verification of E2E suite behavior.

This better ensures we are decoupled from AR, and by its nature builds better support for PORO use cases (which are the common - even if you are using elasticsearch you may return POROish models).

It also validates "resource testing", which will largely replace request specs. This allows us to test resource behavior, including rendered JSON, without going through a controller or endpoint. If this is going to be the testing pattern for real-world apps, let's leverage that same testing pattern internally (dogfood).

It also sets us up to remove Rails/ActiveRecord from the testing stack altogether. I'd like a separate "adapter test suite" to emerge, where "as long as these tests pass, your adapter is considered working". Rails/ActiveRecord could still live within this gem, but be the exemplar implementation of that test suite. This allows "official" adapters to be published, so we can leverage the work of our open-source community to provide adapters for MongoDB, ElasticSearch and Neo4J amonst others.

All tests now pass except for the write-specific Rails Integration tests, which will be tackled later.

Other touches:

Still todo:

richmolj commented 6 years ago

@wadetandy this is on top of https://github.com/jsonapi-suite/jsonapi_compliable/pull/106