Vagrant – Running Rails server in the background

<p> It is pretty easy. First, let&#8217;s create a function for the script block. Put following code on the top of the Vagrant file. </p> </div> </div> </div> <div id="panel-1302-0-0-1" class="so-panel widget widget_sow-editor" data-index="1" data-style="{&quot;background_display&quot;:&quot;tile&quot;}" > <div class="so-widget-sow-editor so-widget-sow-editor-base"> <div class="siteorigin-widget-tinymce textwidget"> <pre>def start_rails_server <<-SHELL cd /vagrant start rails server as a daemon to kill: sudo kill cat tmp/pids/server.pid rails s -d SHELL end <div id="panel-1302-0-0-2" class="so-panel widget widget_sow-editor" data-index="2" data-style="{&quot;background_display&quot;:&quot;tile&quot;}" > <div class="so-widget-sow-editor so-widget-sow-editor-base"> <div class="siteorigin-widget-tinymce textwidget"> <p> Now in the Vagrantfile configuration block, use the script function and set it to run always....

October 18, 2017 · Sinaru Gunawardena

Setting up Ruby SDK for RubyMine with Vagrant

This article is about how you can configure to use the Ruby SDK in your Vagrant image with RubyMine. For this, I have used the joshfng/railsbox Vagrant image because I was using that image for a Rails project. First you have to find where is your Ruby interpreter located for your project. Let’s assume your project lies in the same folder where you have Vagrantfile. In this case, by default the /vagrant folder in the vagrant image will contain your code....

October 12, 2017 · Sinaru Gunawardena

Think differently when the current tests fails

This is a lesson learned from work. SO we use Rials in our project at the workplace. SP for a new requirement, we had to have a validation for a particular attribute of a model. The requirements were specific on where the validation should happen. Say for example for what controller actions. However, the initial idea was tho have the validation at the model so that it will be validated on create and update....

April 25, 2017 · Sinaru Gunawardena

Be careful when using loops in Jasmine specs

Your test automation code is an important tool to evaluate your application. You must ensure your test code is working/testing as you want it to be. the automated tests give confidence for the developer that the application behaves as expected and things are not broken after they change the code. Recently, at our QA phase, the QA found a bug that should have been caught from our test automation. Therefore being suspicious I looked into the code....

February 1, 2017 · Sinaru Gunawardena

Trying out Ansible on local mode

So you might be interested running ansible to configure your local machine. In this article, I’m going to show you the minimum steps that need to install _Vim _ using Ansible on an Ubuntu host machine. Install latest Ansible version from apt Create a folder (let’s call this “ansible”) under home directory Create a file called ‘inventory‘ under the new folder and put following content in the file Create a file called ‘vim....

January 19, 2017 · Sinaru Gunawardena

Trailing whitespaces: what you gonna do about it?

What is a trailing whitespace? Trailing whitespace is any spaces or tabs after the last non-whitespace character on the line until the newline. Background Few months ago, it was raised that PR submitted code tend to have trailing whitespace changes in code diff along with other “real” code changes. This whitespace change is a diff where the change was removing one or more trailing whitespaces from the existing code. We then noticed that the editors we were using were automatically removing trailing whitespaces that were already existed in the code when the file get saved....

January 9, 2017 · Sinaru Gunawardena

Having a newline character at end of file

Background/problem/question: When you create a newfile, and push it to Github, in code diff view, it will say no newline at end of file. Sometimes text editors would also add an EOF newline, if they noticed that the file being edited does not end in a newline, when they are saved (usually it is configured that way by default). Reasoning: In POSIX, a line is a sequence of zero or more non-newline characters plus a terminating character....

January 9, 2017 · Sinaru Gunawardena

Use different conditions to test methods

Let’s say that you have a function that takes an HTML structure and check items. For simplicity, our method would check if each item in the list has a link pointing to type of resource (A). So here can write a test that takes a list with items containing resource A links. Here we expect the function to return true. But this does not guarantee that the function is working as there is another outcome from the function which false....

October 15, 2016 · Sinaru Gunawardena

Don’t commit the first thing that works

I was working on a bug fix on our application with another fellow programmer. First we understood the root cause of the bug and what makes it to happen. All that was good. Then we thought of a solution and applied the first fix that I thought. Code works and bug is fixed, happy days. But wait. Then I thought about the fix and it’s complexity. The bug was causing due to a list that is not getting updated and it was referring to an old memorized list that we lose track once the list is created....

October 9, 2016 · Sinaru Gunawardena

Personal note on how a bug is tracked and fixed at work

Story Today was a good day at work. There was a spike card was mentioning about a bug that was occurring at random actions. However the QAs have found that behavior to be specific for a section of the application. Given the spike card work to track down the cause of this bug was set to 1 day, we manage to find the cause and also fix it with precise thought and action nearly under a 1 day....

August 16, 2016 · Sinaru Gunawardena