-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add sensible defaults to active record objects #30
Comments
Run the test with: bundle exec rake suture This was a little involved and my first-ever attempt using Suture with ActiveRecord inputs & outputs. A few notes. * The rake task is completely divorced from the Rails app & the built-in Rails testing infrastructure/tasks. This seems like a good idea since it'll probably often be the case that users will depend on a database snapshot (or, at the very least, different database setup than the fixtures/factories used in the rest of their test suite) * The test requires the Rails app as well as the item model * The test setup has to establish an AR connection on its own in UpdateQualityTest#setup, which is a little awkward * The test's `:subject` lambda is intentionally identical to the one from ItemsController, so that we can validate that the recordings can be replicated in a controlled automated environment just like they were when we populated db/suture.sqlite3 via exploratory testing * Because ActiveRecord compares items by id, the default comparator is insufficient at least until #30 is resolved
Some thoughts: AR's default I am truly happy to release a Suture 1.0.0 without any AR-specific affordances, but for the fact that by default users will get confusing false positives if they pass in or return AR objects to and from seams. By default, AR will consider two already-persisted objects equivalent if their IDs match. This is definitely a problem with Suture'a default comparator, because drastically-mutated AR objects will be seen as "passing" in Since some woefully high percentage of legacy Ruby classes extend from AR::Base, this is a terrible out-of-the-box experience because it looks like it's passing immediately, the user must recognize it is not, and then figure out the Custom Comparator API to look at just the properties they care about. This is unacceptably bad UX IMO. |
My inclination at this point is to do a few things:
As an aside, I'm saying "ActiveRecord" here since |
id
,created_at
, andupdated_at
.The text was updated successfully, but these errors were encountered: