Comments (2)
Some thoughts: AR's default ==
behavior makes for a really bad out-of-the-box experience with Suture
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 Suture.verify
tests and as comparable in staging (e.g. call_both
mode).
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.
from suture.
My inclination at this point is to do a few things:
- Add to the default comparator a check for
defined?(ActiveRecord::Base)
and if both objects are AR Base, enter a branch to compare them - By default, compare the two objects' attribute hashes
- Expose a config property like
:ignore_active_record_attributes
which defaults tocreated_at
andupdated_at
. - I have no idea how to handle associations for this purpose, though.
As an aside, I'm saying "ActiveRecord" here since attributes
is defined in AR and not on ActiveModel. In practice I'm more interested in solving for the vast majority of cases rather than trying to build-in a super-smart comparator to serve everyone.
from suture.
Related Issues (20)
- Suture.create :after_old and :after_new hooks
- Implement Suture.create :call_both
- Suture.create :on_{new,old,subject}_error handler
- Suture.create :call_old_on_error flag
- Document rails env-specific settings HOT 1
- Rails project + production snapshot
- Suture.verify :after_subject hook
- Override flag to disable the seam / revert to old path
- rake test -> rake unit w/ test as default
- common test parent for unit tests
- Log out an error every time a suture raises
- warn if no calls are found for the provided seam name
- Add progress bar HOT 1
- Document expected_error_types feature
- staging/prod: dup arguments
- Justification for building a custom Docker image instead of using the canonical Ruby one
- call_both: if raise_on_result_mismatch is false and return_old_on_result_mismatch is true, rescue errors from :new path HOT 1
- Errors while writing to sqlite DB HOT 5
- task to explode tests from recorded suture data? HOT 2
- Add a benchmarking mode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from suture.