Testing rake tasks with rspec

This blog post is a continuation of this thread. On trying to write a spec for one of the rake tasks, when trying to invoke the same rake tasks within the same @rspec contexts, for different flows, weirdly the tests failed if I ran the whole suite, but would pass if I ran them separately. — Tasdik Rahman (@tasdikrahman) August 12, 2020 So for example # ./lib/tasks/foo_task.rake desc 'Foo task' namespace :task do task :my_task, [:foo, :bar] => [:baz] do |task, args| ... # does my_task ... end end Now if we try writing a spec a for it ...

October 20, 2020 · 3 min · Tasdik Rahman

The making of bhola - your cert expiration overseer - Part 1

You might have already seen me writing a bit about bhola already on twitter, I wrote a little bit about why I have been building bhola. This post is more of a continuation to this tweet and what I envision it to be moving forward. Do you sometimes wake up, with a call by someone from your team, telling you some SSL cert has expired? Do you keep track of SSL cert expirations on your to do notes or excel sheets? Would you like to be on top of such x509 cert renewals? https://t.co/MVFRZCUlZN is for you (1/n) pic.twitter.com/pj8JHJEkje ...

October 8, 2020 · 7 min · Tasdik Rahman

Structured logging in Rails

This post was originally published in Gojeks engineering blog, here, this post is a cross post of the same If you are on rails, you would have noticed that the rails logs which you get by default are quite verbose and spread across multiple lines, even if the context is of processing just one simple controller action. What I will discuss in this post is how can one sanitize the logs, without losing out on information along with how you can add additional information for your log lines to make full use of the querying features of your logging platform. ...

July 7, 2020 · 6 min · Tasdik Rahman

Introducing Kingsly — The Cert Manager

This was originally published under Gojek’s engineering blog by me, this post is a repost. There’s one thing all devices connected to the Internet have in common — they rely on protocols called SSL/TLS to protect information in transit. SSL/TLS are cryptographic protocols designed to provide secure communication over insecure infrastructure. Any communication over the public internet should be encrypted, for which we need SSL certificates. There are many cases for public communication in GOJEK as well. Some of them are listed below: ...

April 22, 2020 · 7 min · Tasdik Rahman

Object Comparison

When do you say two objects are equal? Taking example of the below two and having ruby as the language, Comparing primitive objects irb(main):001:0> 1 == 1 => true irb(main):002:0> 'tasdik' == 'tasdik' => true irb(main):003:0> Comparing custom objects But what if you are having a custom class defined which has attributes for itself, you can’t really compare them using == default. For example. irb(main):001:0> module Money irb(main):002:1> class Wallet irb(main):003:2> attr_accessor :rupee, :paise irb(main):004:2> irb(main):005:2> def initialize(rupee: 0, paise: 0) irb(main):006:3> @rupee = rupee irb(main):007:3> @paise = paise irb(main):008:3> end irb(main):009:2> end irb(main):010:1> end => :initialize irb(main):011:0> irb(main):012:0> office_wallet = Money::Wallet.new => #<Money::Wallet:0x00007fb4328889c8 @rupee=0, @paise=0> irb(main):013:0> personal_wallet = Money::Wallet.new => #<Money::Wallet:0x00007fb430991290 @rupee=0, @paise=0> irb(main):014:0> irb(main):015:0> office_wallet == personal_wallet => false irb(main):016:0> But as we can see that the two objects have the same attributes, which would be rupee and paise having the same values. They should, logically be the same thing and they should have returned true as a result of the == comparison ...

March 21, 2019 · 5 min · Tasdik Rahman