- Make sure you have configured git tools: see configuring tools.
- Make sure you have updated git aliases: see how to register aliases.
After each commit in our branch, in order to be up-to-date with the integration branch.
#!/bin/bash | |
# store name of current branch | |
BRANCH=$(git branch | grep \* | cut -d ' ' -f2) | |
# checkout master | |
git checkout master | |
# pull the latest changes | |
git pull |
# first we create an empty ActiveRecord::Relation object | |
relation = Model.where(attribute: value) | |
# then we make the relation stub the :[] method | |
# and return whatever values we need | |
relation.stub(:[]).and_return( Model.new({attrs: values})] ) | |
# of course, we can make this too | |
# instead of the step above | |
record = double("Model", :foo => 'bar', :bar => 'baz') |
- Make sure you have configured git tools: see configuring tools.
- Make sure you have updated git aliases: see how to register aliases.
After each commit in our branch, in order to be up-to-date with the integration branch.
This is a tool to find association paths between different models in a rails app.
Example output - the paths from Job to Invoice:
[3] pry(main)> G.from(Job).to(Invoice)
Job.active_fleet_managed_invoice_from_swoop -- Invoice
Job.invoice >- Invoice
Job.owning_company >- Company.fleet_managed_clients -- FleetCompany.end_user_invoices -< Invoice
*.md diff=markdown |
require 'rspec' | |
require 'time' | |
require 'active_support/time' | |
class Foo | |
def float_range_example | |
33 * 5 * Math::PI | |
end | |
def time_range |
find . -type f -name '*.rb' -exec sed -i '' s/FactoryGirl/FactoryBot/ {} + | |
find . -type f -name '*.rb' -exec sed -i '' s/factory_girl/factory_bot/ {} + | |
This: | |
from https://github.com/thoughtbot/factory_bot_rails/issues/247 | |
grep -rl 'FactoryGirl' ./ | xargs sed -i '' 's/FactoryGirl/FactoryBot/g' |
Inspired by dannyfritz/commit-message-emoji
See also gitmoji.
Commit type | Emoji |
---|---|
Initial commit | 🎉 :tada: |
Version tag | 🔖 :bookmark: |
New feature | ✨ :sparkles: |
Bugfix | 🐛 :bug: |
It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time
class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime
steps in:
>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000