Unit tests, WYSIWYG. Ex: spec/sideload_spec.rb. This is where we'd
test that, say, the correct resource name is derived.
"Functional" tests, which test behavior of the low-level API. Ex:
spec/sideloading_spec.rb. Here we'll actually call the low-level
allow_sideload API, with a variety of different options, but without
going through a full application stack.
"Integration" tests, which uses request specs to test Rails with
ActiveRecord end-to-end.
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:
Removed default_page_number. I can't imagine when this would be
anything but 1.
Still todo:
Use jsonapi_spec_helpers instead of the custom helpers there now.
So we have three groups of tests:
spec/sideload_spec.rb
. This is where we'd test that, say, the correct resource name is derived.spec/sideloading_spec.rb
. Here we'll actually call the low-levelallow_sideload
API, with a variety of different options, but without going through a full application stack.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 inspec/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:
default_page_number
. I can't imagine when this would be anything but1
.Still todo:
jsonapi_spec_helpers
instead of the custom helpers there now.