Lucian Ghinda
@lucianghinda.com
1.8K followers 760 following 1.9K posts
Product Engineer, Ruby on Rails Developer ‣ Curator of newsletter.shortruby.com ‣ Helping #Ruby developers design better test cases at https://goodenoughtesting.com
Posts Media Videos Starter Packs
Pinned
lucianghinda.com
Only 7 spots are still available for the #GoodEnoughWorkshop happening on 12 December at 15:00 UTC. Last days for getting the tickets with discounts!

You can buy a ticket here lu.ma/533zg5zq
lucianghinda.com
Pefect :) Thank you
lucianghinda.com
Ah yes, I remember about this helper from RSpec. Consider searching for it when I wrote the post but I am not sure Minitest has something similar.

Will add it to the article. Thank you
lucianghinda.com
Oh I have did not used that. Will add it as another option.

Thank you for sharing it!
lucianghinda.com
In Rails you can also use `.to_fs(:8601)`
In Rails you can also use `.to_fs(:8601)`
lucianghinda.com
iso8601 is defined in Rails as an alias of xmlschema: api.rubyonrails.org/classes/Act...
iso8601 is defined in Rails as an alias of xmlschema: https://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html#method-i-xmlschema
lucianghinda.com
And of course my preferred method is to use iso8601
And of course my preferred method is to use iso8601
lucianghinda.com
Another option would be to use `.to_i` which returns the value as integer Epoch seconds where subseconds are truncated.
Another option would be to use `.to_i` which returns the value as integer Epoch seconds where subseconds are truncated.
lucianghinda.com
ActiveSupport::TimeWithZone#change is an alias for xmlschema see api.rubyonrails.org/classes/Act...
ActiveSupport::TimeWithZone#change is an alias for xmlschema see https://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html#method-i-xmlschema
lucianghinda.com
One option is to use `.change` to set microseconds to zero.
One option is to use `.change` to set microseconds to zero.
lucianghinda.com
When comparing two times (TimeWithZone, Time, DateTime) in Ruby on Rails you might get into issues if there are delays between execution time.
When comparing two times (TimeWithZone, Time, DateTime) in Ruby on Rails you might get into issues if there are delays between execution time.
lucianghinda.com
If microsecond precision is not required when testing Time, DateTime, or ActiveSupport::TimeWithZone, use iso8601 to assert equality between different times.

Use time.iso8601
Use time.to_fs(:iso8601)
If microsecond precision is not required when testing Time, DateTime, or ActiveSupport::TimeWithZone, use iso8601 to assert equality between different times.  Use time.iso8601 Use time.to_fs(:iso8601)
lucianghinda.com
With SQLite things are automatically solved.

But with PSQL/MYSQL then yes, this issue is still there.
lucianghinda.com
I even contemplated the idea to automatically do bin/rails db:reset when switching folders :) but it was just a crazy idea :))
lucianghinda.com
Oh yes, my usage of git stash is down in these years. I still use it but more to save various experiments/spikes that I don't want to commit
lucianghinda.com
No, I keep the same DB.
And anytime I need to migrate I always do:
bin/rails db:reset
+
bin/rails db:migrate
on the branch that changes the DB
lucianghinda.com
The pairing one because I want to access any branch quickly I'm reviewing while still seeing the main branch. Having separate folders makes switching between them easy.

Additionally, I use folders for each feature or bug I'm working on.
lucianghinda.com
Why these folders:

I always maintain a local copy of the current main branch. This helps me review changes or start something new, as I can quickly verify how production functions if the main branch is what's deployed.
lucianghinda.com
Say I work on the short_ruby project and set up the following structure:

`short_ruby/main`: Main branch.
`short_ruby/pairing`: For code reviews, exploring changes, or sharing drafts.
`short_ruby/feature_<id>`: A temporary worktree for each feature, deleted when complete.
lucianghinda.com
I've been using git worktree for at least five years now.
Here's how I set things up:
How I use git worktree