<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-6516585789204376609</atom:id><lastBuildDate>Thu, 17 Oct 2024 16:07:58 +0000</lastBuildDate><category>Ruby</category><category>learnings</category><category>Flash messages</category><category>Ruby on Rails</category><category>Ruby on RailsTags flash messages</category><category>engineering</category><category>flash messages in rails</category><category>twitter</category><category>twitter bootstrap</category><category>Design pattern</category><category>Observer pattern</category><category>butterfly effect</category><category>career</category><category>computer science</category><category>life</category><category>startup</category><category>tests</category><category>unit tests</category><title>Surya Raj Tripathi</title><description>Work hard, play smart. Such is life..!</description><link>https://surya.rajtripathi.com/</link><managingEditor>noreply@blogger.com (Surya Tripathi)</managingEditor><generator>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6516585789204376609.post-1406803943938106576</guid><pubDate>Fri, 21 Jun 2019 22:08:00 +0000</pubDate><atom:updated>2019-06-22T22:26:56.562+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">engineering</category><category domain="http://www.blogger.com/atom/ns#">tests</category><category domain="http://www.blogger.com/atom/ns#">unit tests</category><title>Why should I write tests?</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:8,&#39;w&#39;:653,&#39;h&#39;:28,&#39;abs_x&#39;:245,&#39;abs_y&#39;:143}&quot;&gt;
Why? Why..? Why....??&lt;/h2&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:55,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:190}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:55,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:216}&quot;&gt;
This is an easy one. Because we do not want to ship our code to production without testing it.&lt;/div&gt;
&lt;/div&gt;
&lt;h2 bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:93,&#39;w&#39;:653,&#39;h&#39;:28,&#39;abs_x&#39;:245,&#39;abs_y&#39;:228}&quot;&gt;
But why? Really?&lt;/h2&gt;
&lt;h3 bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:141,&#39;w&#39;:653,&#39;h&#39;:66,&#39;abs_x&#39;:245,&#39;abs_y&#39;:276}&quot;&gt;
Why really? I mean, I could just run my code and test(it is a faster way to do it for me). I could just ctrl+f5 the page and test my code. Why should I put in the efforts and time to write those tests? (Change-My-Mind.png)&lt;/h3&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:226,&#39;w&#39;:653,&#39;h&#39;:36,&#39;abs_x&#39;:245,&#39;abs_y&#39;:361}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:226,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:36,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:387}&quot;&gt;
Yes, It is really important to know why should I write the tests before I start writing important tests. Otherwise, it&#39;d feel more of a burden than the right cause.&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:262,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:397}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:262,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:423}&quot;&gt;
&lt;br bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:262,&#39;w&#39;:0,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:397}&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:280,&#39;w&#39;:653,&#39;h&#39;:38,&#39;abs_x&#39;:245,&#39;abs_y&#39;:415}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:280,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:36,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:441}&quot;&gt;
It&#39;s all cool if it is some static content change and you and your peers have verified it. You could just compare the text given for task with the updated on the page. Tests can&#39;t catch grammar mistakes. 🙂&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:318,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:453}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:316,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:477}&quot;&gt;
&lt;br bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:318,&#39;w&#39;:0,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:453}&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:336,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:471}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:334,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:495}&quot;&gt;
Let&#39;s say for an example:&lt;/div&gt;
&lt;/div&gt;
&lt;hr bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:362,&#39;w&#39;:653,&#39;h&#39;:2,&#39;abs_x&#39;:245,&#39;abs_y&#39;:497}&quot; /&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:372,&#39;w&#39;:653,&#39;h&#39;:108,&#39;abs_x&#39;:245,&#39;abs_y&#39;:507}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:370,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:108,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:531}&quot;&gt;
&quot;&lt;span bis_size=&quot;{&#39;x&#39;:22,&#39;y&#39;:372,&#39;w&#39;:37,&#39;h&#39;:18,&#39;abs_x&#39;:251,&#39;abs_y&#39;:507}&quot; style=&quot;color: #222222;&quot;&gt;Jessie&lt;/span&gt;&quot;(who is part of the team Rocket ) added username, password, and age fields for the sign-up form. &quot;&lt;span bis_size=&quot;{&#39;x&#39;:61,&#39;y&#39;:390,&#39;w&#39;:37,&#39;h&#39;:18,&#39;abs_x&#39;:290,&#39;abs_y&#39;:525}&quot; style=&quot;color: #222222;&quot;&gt;Jessie&lt;/span&gt;&quot; went to the page and tested that the fields are visible, accepting the data, validating the username(uniqueness and some char length - the strictness in the column with varchar length as well, etc), some validation for the password(8 min chars, numbers, special char etc), and age fields(say minimum 13 years old). &quot;&lt;span bis_size=&quot;{&#39;x&#39;:180,&#39;y&#39;:444,&#39;w&#39;:37,&#39;h&#39;:18,&#39;abs_x&#39;:409,&#39;abs_y&#39;:579}&quot; style=&quot;color: #222222;&quot;&gt;Jessie&lt;/span&gt;&quot; deployed the code and &lt;s bis_size=&quot;{&#39;x&#39;:375,&#39;y&#39;:444,&#39;w&#39;:148,&#39;h&#39;:18,&#39;abs_x&#39;:604,&#39;abs_y&#39;:579}&quot;&gt;lived happily ever after&lt;/s&gt;&amp;nbsp;started working on other tasks.&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:480,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:615}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:478,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:639}&quot;&gt;
&lt;br bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:480,&#39;w&#39;:0,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:615}&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:498,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:633}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:496,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:657}&quot;&gt;
&amp;gt;&amp;gt; Fast-Forward 2 months...&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:516,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:651}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:514,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:675}&quot;&gt;
&lt;br bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:516,&#39;w&#39;:0,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:651}&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:534,&#39;w&#39;:653,&#39;h&#39;:54,&#39;abs_x&#39;:245,&#39;abs_y&#39;:669}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:532,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:54,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:693}&quot;&gt;
&quot;James&quot; from team Stars(newly forked from team Rocket) decided it is high time we start collecting emails of our users since we&#39;re seeing a lot of signups. We&#39;re ready to bother our users with our evil product plans. We just need their emails now to get into the endgame.&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:588,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:723}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:586,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:747}&quot;&gt;
&lt;br bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:588,&#39;w&#39;:0,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:723}&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:606,&#39;w&#39;:653,&#39;h&#39;:90,&#39;abs_x&#39;:245,&#39;abs_y&#39;:741}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:604,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:90,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:765}&quot;&gt;
So, &quot;James&quot; takes up the task, adds a new field on sign-up page(called email off-course), looks at the username&#39;s uniqueness validation code, insert their email field there and finds out the page is not accepting the length more than 6 chars. Uh, oh, the length needs to be increased because email could be &quot;spammyuserwithexample@randompokemon.com&quot;, changes the minimum length to 15, tests the page the same way &quot;&lt;span bis_size=&quot;{&#39;x&#39;:147,&#39;y&#39;:678,&#39;w&#39;:43,&#39;h&#39;:18,&#39;abs_x&#39;:376,&#39;abs_y&#39;:813}&quot; style=&quot;color: #222222;&quot;&gt;Jessie&quot;&lt;/span&gt; did because &quot;James&quot; admires &quot;&lt;span bis_size=&quot;{&#39;x&#39;:392,&#39;y&#39;:678,&#39;w&#39;:43,&#39;h&#39;:18,&#39;abs_x&#39;:621,&#39;abs_y&#39;:813}&quot; style=&quot;color: #222222;&quot;&gt;Jessie&quot;&lt;/span&gt; and follows their footsteps.&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:696,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:831}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:694,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:855}&quot;&gt;
&lt;br bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:696,&#39;w&#39;:0,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:831}&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:714,&#39;w&#39;:653,&#39;h&#39;:54,&#39;abs_x&#39;:245,&#39;abs_y&#39;:849}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:712,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:54,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:873}&quot;&gt;
Everything is good because UI validation takes care of limiting username to 6 chars and &quot;James&quot; was more focused on testing the email stuff and did not try a case where username has more than 6 chars because UI took care of it. The code is deployed.&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:768,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:903}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:766,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:927}&quot;&gt;
&lt;br bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:768,&#39;w&#39;:0,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:903}&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:786,&#39;w&#39;:653,&#39;h&#39;:72,&#39;abs_x&#39;:245,&#39;abs_y&#39;:921}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:784,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:72,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:945}&quot;&gt;
The next day &quot;&lt;span bis_size=&quot;{&#39;x&#39;:110,&#39;y&#39;:786,&#39;w&#39;:47,&#39;h&#39;:18,&#39;abs_x&#39;:339,&#39;abs_y&#39;:921}&quot; style=&quot;color: #222222;&quot;&gt;Jessie&quot;&amp;nbsp;&lt;/span&gt; and &quot;James&quot; are staring at 100+ exception emails stating DB could not save username field as the length size exceeds the limit. Because of a notorious user called Ash who with the help of his friend Pikachu, decided to write a script which spams with random and lengthy usernames and emails on the signup page&#39;s endpoint(before the spam filter could block them).&lt;/div&gt;
&lt;/div&gt;
&lt;hr bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:866,&#39;w&#39;:653,&#39;h&#39;:2,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1001}&quot; /&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:876,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1011}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:874,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:1035}&quot;&gt;
&lt;br bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:876,&#39;w&#39;:0,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1011}&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:894,&#39;w&#39;:653,&#39;h&#39;:36,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1029}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:892,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:36,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:1053}&quot;&gt;
Learnings from the example - Both devs tested &lt;strong bis_size=&quot;{&#39;x&#39;:319,&#39;y&#39;:894,&#39;w&#39;:65,&#39;h&#39;:18,&#39;abs_x&#39;:548,&#39;abs_y&#39;:1029}&quot;&gt;their own&lt;/strong&gt; code. Code worked in their context. Things still went &lt;s bis_size=&quot;{&#39;x&#39;:79,&#39;y&#39;:912,&#39;w&#39;:34,&#39;h&#39;:18,&#39;abs_x&#39;:308,&#39;abs_y&#39;:1047}&quot;&gt;south&lt;/s&gt;... &lt;s bis_size=&quot;{&#39;x&#39;:129,&#39;y&#39;:912,&#39;w&#39;:33,&#39;h&#39;:18,&#39;abs_x&#39;:358,&#39;abs_y&#39;:1047}&quot;&gt;north&lt;/s&gt;... &lt;s bis_size=&quot;{&#39;x&#39;:179,&#39;y&#39;:912,&#39;w&#39;:119,&#39;h&#39;:18,&#39;abs_x&#39;:408,&#39;abs_y&#39;:1047}&quot;&gt;the House of Stark&lt;/s&gt;... Jeez... this is hard. You got the point, right?&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:930,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1065}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:928,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:1089}&quot;&gt;
&lt;br bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:930,&#39;w&#39;:0,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1065}&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:948,&#39;w&#39;:653,&#39;h&#39;:54,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1083}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:946,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:54,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:1107}&quot;&gt;
Had &quot;Jessie&quot; written code(specs) for the actual code which asserts the limit cannot be more than(say 6 chars). &quot;James&quot; wouldn&#39;t have been able to deploy the code change because of the assertion failures during the CI process.&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:1002,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1137}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:1000,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:1161}&quot;&gt;
&lt;br bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:1002,&#39;w&#39;:0,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1137}&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:1020,&#39;w&#39;:653,&#39;h&#39;:36,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1155}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:1018,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:36,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:1179}&quot;&gt;
Which means while we just run the code and verify all the scenarios by ourselves is a good thing, writing those thoughts(scenarios manually tested) down in code(specs) is much better.&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:1056,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1191}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:1054,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:1215}&quot;&gt;
&lt;br bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:1056,&#39;w&#39;:0,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1191}&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:1074,&#39;w&#39;:653,&#39;h&#39;:18,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1209}&quot;&gt;
&lt;div bis_size=&quot;{&amp;quot;x&amp;quot;:16,&amp;quot;y&amp;quot;:1072,&amp;quot;w&amp;quot;:653,&amp;quot;h&amp;quot;:18,&amp;quot;abs_x&amp;quot;:245,&amp;quot;abs_y&amp;quot;:1233}&quot;&gt;
This change in mindset leads to:&lt;/div&gt;
&lt;/div&gt;
&lt;ul bis_size=&quot;{&#39;x&#39;:16,&#39;y&#39;:1108,&#39;w&#39;:653,&#39;h&#39;:180,&#39;abs_x&#39;:245,&#39;abs_y&#39;:1243}&quot;&gt;
&lt;li bis_size=&quot;{&#39;x&#39;:56,&#39;y&#39;:1108,&#39;w&#39;:613,&#39;h&#39;:36,&#39;abs_x&#39;:285,&#39;abs_y&#39;:1243}&quot;&gt;Increase in productivity because other devs wouldn&#39;t have to worry about breaking a flow unknown to them, as the specs would tell them by turning red.&lt;/li&gt;
&lt;li bis_size=&quot;{&#39;x&#39;:56,&#39;y&#39;:1144,&#39;w&#39;:613,&#39;h&#39;:36,&#39;abs_x&#39;:285,&#39;abs_y&#39;:1279}&quot;&gt;Makes it easy to change code without worrying about breaking the behavior of the functionality.&lt;/li&gt;
&lt;li bis_size=&quot;{&#39;x&#39;:56,&#39;y&#39;:1180,&#39;w&#39;:613,&#39;h&#39;:72,&#39;abs_x&#39;:285,&#39;abs_y&#39;:1315}&quot;&gt;Saves more time than manual testing - YES. Imagine testing each field&#39;s behavior yourself after every code change, and then imagine just running specs which already know what all to cover. Now, imagine others in the team, who don&#39;t have to go through the same fields testing manually who can just run those already crafted specs. Hence the bullet point 1.&lt;/li&gt;
&lt;li bis_size=&quot;{&#39;x&#39;:56,&#39;y&#39;:1252,&#39;w&#39;:613,&#39;h&#39;:18,&#39;abs_x&#39;:285,&#39;abs_y&#39;:1387}&quot;&gt;Specs often lead to the self-documentation of your code.&lt;/li&gt;
&lt;li bis_size=&quot;{&#39;x&#39;:56,&#39;y&#39;:1270,&#39;w&#39;:613,&#39;h&#39;:18,&#39;abs_x&#39;:285,&#39;abs_y&#39;:1405}&quot;&gt;Confidence in all of your deliverables.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description><link>https://surya.rajtripathi.com/2019/06/why-should-i-write-tests.html</link><author>noreply@blogger.com (Surya Tripathi)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6516585789204376609.post-5265324964106929024</guid><pubDate>Sun, 25 Feb 2018 15:20:00 +0000</pubDate><atom:updated>2018-02-25T21:02:33.891+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Flash messages</category><category domain="http://www.blogger.com/atom/ns#">flash messages in rails</category><category domain="http://www.blogger.com/atom/ns#">learnings</category><category domain="http://www.blogger.com/atom/ns#">Ruby</category><category domain="http://www.blogger.com/atom/ns#">Ruby on Rails</category><category domain="http://www.blogger.com/atom/ns#">Ruby on RailsTags flash messages</category><category domain="http://www.blogger.com/atom/ns#">twitter</category><category domain="http://www.blogger.com/atom/ns#">twitter bootstrap</category><title>Rails 4 flash messages using Twitter Bootstrap 3</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I’ve always wondered if there’s any better way to deal with flash messages in Ruby on Rails.&lt;br /&gt;
&lt;br /&gt;
In all the Ruby on Rails tutorials you see, they’ll tell you to keep the code DRY, isn’t so? Right?&lt;br /&gt;
So what you do?&lt;br /&gt;
&lt;br /&gt;
Create partial&amp;nbsp;&lt;strong&gt;shared/_error_messages.html.erb&lt;/strong&gt;&amp;nbsp;or&amp;nbsp;&lt;strong&gt;shared/_flash_messages.html.erb&lt;/strong&gt;&amp;nbsp;and write your flash&amp;nbsp;messages displaying code into this file and call it from all other places in your views? Wait!! While keeping your flash messages in partial is a good thing, but don’t you think you can do it in a more better way?? Yes, better way!&lt;br /&gt;
&lt;br /&gt;
I found this&amp;nbsp;&lt;a href=&quot;https://gist.github.com/roberto/3344628&quot;&gt;gist.&lt;/a&gt;&amp;nbsp;While I was reading this gist a thought triggered in my mind that why not remove a part and make&amp;nbsp;a method which displays the flash messages. So,&amp;nbsp;I created this&amp;nbsp;&lt;a href=&quot;https://gist.github.com/suryart/7418454&quot;&gt;gist&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/suryart/7418454.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
Now, the application doesn’t have to load another part for just displaying the&amp;nbsp;flash messages. Guess what? You saved few milliseconds of your action load time! Don’t believe? Try it yourself! You’re welcome!&lt;/div&gt;
</description><link>https://surya.rajtripathi.com/2018/02/rails-4-flash-messages-using-twitter.html</link><author>noreply@blogger.com (Surya Tripathi)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6516585789204376609.post-1614119087707635010</guid><pubDate>Sun, 25 Feb 2018 15:14:00 +0000</pubDate><atom:updated>2018-02-25T21:01:51.017+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">butterfly effect</category><category domain="http://www.blogger.com/atom/ns#">career</category><category domain="http://www.blogger.com/atom/ns#">computer science</category><category domain="http://www.blogger.com/atom/ns#">engineering</category><category domain="http://www.blogger.com/atom/ns#">learnings</category><category domain="http://www.blogger.com/atom/ns#">life</category><category domain="http://www.blogger.com/atom/ns#">Ruby</category><category domain="http://www.blogger.com/atom/ns#">startup</category><title>How I started my career after graduation</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;article class=&quot;post-35 post type-post status-publish format-standard hentry category-butterfly-effect category-career category-computer-science category-engineering category-learnings category-life category-ruby category-startup tag-career tag-life tag-ruby-2 tag-ruby-on-rails&quot; id=&quot;post-35&quot;&gt;&lt;div class=&quot;entry-content&quot;&gt;
I am not sure who’s going to read all the stuff I have put below. But, whatever I’ve written is my own personal experience, gained over a certain period of time.&lt;br /&gt;
&lt;br /&gt;
I completed my engineering from so-called computer science &amp;amp; engineering(&lt;em&gt;I am still looking for&amp;nbsp;that guy who told me that software engineers have a great life, and encouraged me to go for CSE. He also talked&amp;nbsp;my father into it with the boosted words of wisdom of a software engineer, he told software engineers to spend life in an AC room and earn good money for checking emails. When I find this guy&amp;nbsp;then somebody’s gonna gets hurt pretty badly! :P&lt;/em&gt;) in July 2010. I had no job a the college couldn’t afford to get any company for campus placement. So, I moved to Bangalore in a hope of getting a job and started hunting with other folks I met during that time. Later, I got a job in a pretty well-established outsourcing company(organization size was about 40 employees, it wasn’t a startup though) as their first and only testing(QA) engineer after 2 months(on 28th September 2010 to be precise) of struggle. The job description was more of testing applications manually of all the developers in the company, who works on completely different technologies like PHP, Objective-C, Java, Android Applications Development, Flex, and Ruby on Rails(&lt;em&gt;web application framework&lt;/em&gt;).&lt;br /&gt;
&lt;br /&gt;
This gave me the opportunity to interact with each and every developer there, I learned in which language&amp;nbsp;they code and how they code. Basically, I got the domain knowledge which I actually needed to understand how things work in a small but established IT company. So, this was the time when I was doing a lot of manual jobs than learning any language(&lt;em&gt;or writing any code for that matter :/&lt;/em&gt;). And, after two months one of the developers(whom I used to talk a lot during work) from ‘Ruby on Rails’ team decided to leave(as he might have gotten a good job offer somewhere else). Now, head(YES, head as there was no manager) of the company told me to learn ‘Ruby on Rails’ from this guy who was leaving and serving his notice period. But wait, I had to learn everything when I am done with&amp;nbsp;my work(which is testing others’ work), and as soon as I complete my assigned tasks, it used to be the time for everybody to leave for the day. I didn’t have any idea how to handle this situation, so after a while, I decided to stay late at night in the office and read about ‘Ruby on Rails’. I still remember how I downloaded few tutorials and doing what was shown in the videos. When I used to get stuck, I ask this guy for help next day. This worked like a charm however, it wasn’t even a month and I realized that I’ve started burning my peace of mind(staying late till&amp;nbsp;11:30 PM – 12:00 AM and then coming back to the office at 9:00 AM). As the time passed, I wasn’t sure enough to work on&amp;nbsp;real projects(like a real project), and time passed really fast I’d say. All I could understand was the basics on this new language and framework called “Ruby” and “Ruby on Rails”, hell, I never heard of both until I joined this company and now they want to me deliver awesome looking projects right in production for the clients.&lt;br /&gt;
&lt;br /&gt;
Yet, I did one thing really&amp;nbsp;well in one month, which was understanding of the flow of applications(routing and mapping routes to controllers) in ‘Ruby on Rails’. 17th January 2011 was the time when one of my cousin brothers was getting married and I had to go to my hometown, so I took leaves for 5 days. When I came back to Bangalore on 22nd January 2011 and if I’d knew what’s coming then I would have been prepared for it but this was completely unanticipated. I got a call from a guy(who used to handle the accounting department in this company) on 23rd January 2011(which was a Sunday) and he said: “There’s no need to come to office from tomorrow(Monday)”. I was surprised and shocked&amp;nbsp;at the same time, I asked this guy “what happened? why?” a couple of times but he repeated the same thing again and once he mentioned that he got orders from the head to convey this message to me. Completely unaware of the issue, I went to the office to meet this man who happens to be the head of the company. When I reached the office, I was asked to leave the office premise&amp;nbsp;by this account guy(who spoke to me a day before and delivered the news over the phone) again, right in my face. But, I insisted to let me at least meet the head of the company and after a couple of repetitive requests, he let me enter to this ‘the head’ of the company’s cabin.&lt;br /&gt;
&lt;br /&gt;
He(head of the company) said: why are you here? we don’t need you to work here. You may go now.&lt;br /&gt;
I asked: Why? What did I do wrong that has made you take such a&amp;nbsp;decision of&amp;nbsp;firing&amp;nbsp;me?&lt;br /&gt;
He said(in an angry voice, I guess): I found your RESUME on Naukri.com and I think you’re looking for a change, we can’t afford to train someone and let them find a job elsewhere. He added I let you work here, I nurtured you(as if I was getting paid for sitting in an AC cabin to do nothing). I challenge you(me), you are&amp;nbsp;not even worth getting&amp;nbsp;a job in any other company. Nobody is going to hire you for even 10000 INR/month in Bangalore.&lt;br /&gt;
&lt;br /&gt;
After listening&amp;nbsp;to all that I came out of his cabin without a single&amp;nbsp;word. I have to admit, that was an extremely bad&amp;nbsp;day for me.&lt;br /&gt;
&lt;br /&gt;
After two days, I got a call from this friend/colleague I used to talk in this company which threw me like a dust out of the window. I told him what happened, and I have to admit, this guy really helped me in getting out of this worse situation. He was being pursued by a startup for which he didn’t wanna work for. So, he diverted his interview call to me. I went to take up the interview, as a startup, there were just COO, CTO, and lead designer of this venture. They asked me a few questions in which I was pretty sound from my past self-trainings. I finally got the job.&lt;br /&gt;
&lt;br /&gt;
Here(startup) I met the most incredible people. This startup’s CTO: Prashanth HN(https://twitter.com/prashanth), COO: Vivek SP(https://twitter.com/viveksp), and the lead designer: Soujanya Sreenath(https://twitter.com/soujshri). I must say, each and every person has inspired me every day at work.&lt;br /&gt;
&lt;br /&gt;
They even gave me a certain time frame to learn things on my own on dummy projects and sometimes they used to give tips on how I should go about solving an issue. What I was, and how I turned out to be is only because of these people.&lt;br /&gt;
&lt;br /&gt;
After working here, I couldn’t find a single reason to not to work for a startup. Here is what I’ve learned:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;How to deal with people.&lt;/li&gt;
&lt;li&gt;How to deal with projects.&lt;/li&gt;
&lt;li&gt;How to deal with code.&lt;/li&gt;
&lt;li&gt;How to deal with bugs in production.&lt;/li&gt;
&lt;li&gt;How to enjoy little moments in life.&lt;/li&gt;
&lt;li&gt;How to be a doer than a thinker.&lt;/li&gt;
&lt;li&gt;How to take decisions which makes sense.&lt;/li&gt;
&lt;li&gt;How to laugh at times on PJs.&lt;/li&gt;
&lt;li&gt;How to face things, be calm and have patience.&lt;/li&gt;
&lt;li&gt;How to be ready for your own startup.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
And more importantly why I should be doing my own startup instead of working for someone else. Now, one&amp;nbsp;should realize this themselves. Who would encourage a lost guy in the darkness of unemployment to produce employment?&lt;br /&gt;
&lt;br /&gt;
After working for 2 years and 11 months, I left this startup for a couple of reasons(one reason would be to try hard to do a startup of my own). Now, I am pretty much confident to do anything in life. I am no longer a boy who is scared to be left alone in the darkness of unemployment. Because, if I lose my job this time, I will be happier than being sad and perhaps give my 100% to do something of my own. I am in the process of building something of my own now, but cannot give 100% because of the duty calls.&lt;br /&gt;
&lt;br /&gt;
I see all this as a&amp;nbsp;&lt;a href=&quot;http://web.archive.org/web/20161018063042/https://en.wikipedia.org/wiki/Butterfly_effect&quot;&gt;butterfly effect&lt;/a&gt;. Every incident of my life is very well connected to anything that happens in future.&lt;br /&gt;
&lt;br /&gt;
Again, this was my own personal experience and needed this golden lifetime experience to be logged somewhere&amp;nbsp;so,&amp;nbsp;I did it here. Thank you for being patient with me and reading all this. :)&lt;/div&gt;
&lt;/article&gt;&lt;/div&gt;
</description><link>https://surya.rajtripathi.com/2018/02/how-i-started-my-career-after-graduation.html</link><author>noreply@blogger.com (Surya Tripathi)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6516585789204376609.post-1359398523945615156</guid><pubDate>Sun, 25 Feb 2018 15:05:00 +0000</pubDate><atom:updated>2018-02-25T20:59:41.147+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Design pattern</category><category domain="http://www.blogger.com/atom/ns#">Observer pattern</category><category domain="http://www.blogger.com/atom/ns#">Ruby</category><title>The Observer Design Pattern in Ruby!!</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;a href=&quot;http://web.archive.org/web/20161019121652/https://en.wikipedia.org/wiki/Software_design_pattern&quot; target=&quot;_blank&quot; title=&quot;design patterns&quot;&gt;Design patterns&lt;/a&gt;&amp;nbsp;have always been a vital part of a quality software development. In fact, they let developers work in a team effectively by setting up the common ground rules for a problem.&lt;br /&gt;
In this post, I’d like to introduce you to&amp;nbsp;&lt;a href=&quot;http://web.archive.org/web/20161019121652/https://en.wikipedia.org/wiki/Observer_pattern&quot; target=&quot;_blank&quot; title=&quot;The Observer Pattern&quot;&gt;The Observer Pattern&lt;/a&gt;. Basically, Observer is a&amp;nbsp;&lt;strong&gt;behavioral type,&amp;nbsp;&lt;/strong&gt;or&amp;nbsp;publish/subscribe pattern which allows a number of observer objects to see an event. So, if an observer object is subscribed to an event on the subject, on a change/update of that event on the subject will publish/reflect the changes on the observing objects as well.&lt;br /&gt;
For example, An electric bulb’s state(on/off) will depend on the state of the switch it is directly connected to. So, if I turn the switch on then the bulb will be turned on, and vice-a-versa.&lt;br /&gt;
Now, think switch and bulb as objects. These objects will have two states: either on or off. However, the bulb’s state will entirely depend on the switch’s state.&lt;br /&gt;
&lt;br /&gt;
Bored reading theoretical stuff?? Let’s see some code in action:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/suryart/0c67490fa44eeabbefa2a9ab13725cd1.js&quot;&gt;&lt;/script&gt; The code above shows an Appliance class, which I thought makes more sense. Since we have a bulb, fan, A.C. which are ultimately electrical appliances which have different attributes(of course) except one, which is the state(on/off).&lt;br /&gt;
&lt;br /&gt;
One thing you’ll notice when you see your switch is that, it is integrated on a switch box, so we do that in SwitchBox class. Later we integrate all switches in SwitchBox using Switch class.&lt;br /&gt;
&lt;br /&gt;
Now, all we need is to run the code.&lt;br /&gt;
&lt;br /&gt;
Just in case if you didn’t like something or wanna report an issue then here is &lt;a href=&quot;https://github.com/suryart/ruby_concepts/tree/master/design_patterns/observer&quot; target=&quot;_blank&quot;&gt;the link to the code in the Github repository&lt;/a&gt;.&lt;/div&gt;
</description><link>https://surya.rajtripathi.com/2018/02/the-observer-design-pattern-in-ruby.html</link><author>noreply@blogger.com (Surya Tripathi)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6516585789204376609.post-1003515952258957079</guid><pubDate>Sun, 25 Feb 2018 14:40:00 +0000</pubDate><atom:updated>2018-02-25T20:58:21.086+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Flash messages</category><category domain="http://www.blogger.com/atom/ns#">flash messages in rails</category><category domain="http://www.blogger.com/atom/ns#">learnings</category><category domain="http://www.blogger.com/atom/ns#">Ruby</category><category domain="http://www.blogger.com/atom/ns#">Ruby on Rails</category><category domain="http://www.blogger.com/atom/ns#">Ruby on RailsTags flash messages</category><category domain="http://www.blogger.com/atom/ns#">twitter</category><category domain="http://www.blogger.com/atom/ns#">twitter bootstrap</category><title>Module - Include or Extend? and Mixin</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div&gt;
&lt;b&gt;Multiple Inheritance&lt;/b&gt; – A class is suppose to show multiple inheritance when that class can inherit characteristics and features from more than one superclass(parent class).&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Mixin – Since Ruby does not support multiple inheritances but has an amazing implementation of achieving the same by eliminating the need for multiple inheritances using the module, is also known as the mixin.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Mixin&amp;nbsp;-&lt;/b&gt; can be achieved by using either include or extend keywords inside a class. The difference between include and extend is:&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;include : mixes in specified module methods as instance methods in the target class.&lt;/li&gt;
&lt;li&gt;extend : mixes in specified module methods as class methods in the target class.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
Here is a small code example:&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/suryart/15d27dca601687e2ad0da1ffa8cd89f1.js&quot;&gt;&lt;/script&gt; Still, have a question? Feel free to contact me!!&lt;/div&gt;
&lt;/div&gt;
</description><link>https://surya.rajtripathi.com/2018/02/module-include-or-extend-and-mixin.html</link><author>noreply@blogger.com (Surya Tripathi)</author><thr:total>1</thr:total></item></channel></rss>