Beginners code ruby ruby on rails rubygem unit tests

Read Minitest To Learn Ruby

I continue my quest to master Ruby. Lately I’ve been reading the source code for Minitest. Minitest is a Ruby gem to help developers write unit tests. In addition, you can also use Minitest to write specs and do your development BDD style. The gem also has support for mocking and benchmarking.

Let’s concentrate our attention on the assertions.rb file located at Inside that file, we can see that the assert method takes 2 parameters: test and msg. Below is the actual Ruby code.

#  Fails unless +test+ is truthy

def assert test, msg = nil
  self.assertions += 1
  unless test then
    msg ||= "Failed assertion, no message given."
    msg = if Proc === msg
    raise Minitest::Assertion, msg

The first line inside the assert method, self.assertions += 1, is increasing the assertions variable by 1. This value is display after your unit tests are run. Something like 10 assertions, 5 pass, 5 failed. Next we see the unless keyword followed by test and a block. Having the comment above this method, really helps us understand what unless is. The unless block will be executed if test is false. Inside that block, we set a default message to msg if msg is nil or false. The next line checks if the msg passed to our method is a Proc object. If msg is a Proc object, msg will be assigned the value returned from invoking the block. To learn more about the Proc class, go to the official Ruby docs. Then we raise an exception by calling Minitest::Assertion and passing the msg variable.

After executing the unless block, we return true.

I believe Minitest is an excellent resource to learn Ruby. It’s a small code base compared to other projects.


Joining MD Buyline


It’s been 5 weeks since I joined MD Buyline as a Senior .Net Developer. I think it is a good time to write about my new job. Here are the 3 things I like about working at MD Buyline:

1. Commute

Our offices are located at 75 and Mockingbird. From my house to the office, it takes me 30 minutes. But since I live very close to the Westmoreland station, I have decided to take the train. I take the red line train and it takes me 40 minutes to reach the office. During the ride, I read books and sometimes I write for my blog. When I’m not reading or writing, I just sit back and relax.

I feel that my stress level has going down. When I was working at Verizon, I was driving an average of 90 minutes per day. Now that I take the train, I feel more relaxed. I’m also saving money on gas. In addition, my car mileage has not increase much. I really like that.


2. Small Team

We are a small team of 6 developers. On average, we have 2 or 3 developers per project. This setup allows us to solve problems quickly. When we have technology problems or issues with the code, we can email our group and someone will have a recommendation to solve it. I like the small teams because the communication does not get lost. When I was working in bigger team, the resolution to a problem had to go thru different layers of management.

3. Technology

Before joining MD Buyline, I had the opportunity to work in an Asp.Net MVC 3 project. The experience gained in that project has allowed me to be comfortable working here. Most of our applications are using MVC. We are also heavily involved with web services and unit testing. I also had the opportunity to work with MongoDb, a nosql database. In addition to MongoDb, we also use Sql Server, and PostgreSql. In terms of continuous integration and delivery, we are using to do our automated builds. There is room for improvement in our continuous delivery tools. I had experience in that area and hopefully we can fully automate our deployments.

It’s only been 5 weeks in my new job and I really like the people and culture of the company.

General Git Visual Studio

Visual Studio 2013 Git tip


I started a new project using Visual Studio 2013 and git. Our repository is hosted at Atlassian’s bitbucket. They also have a nice git client for windows that supports ssh and https. I downloaded that tool and was able to setup my repository using ssh.

Since Visual Studio 2013 has built in integration with Git, I was under the impression that ssh was also supported. I was wrong. Microsoft is using the open source library called libgit2 and that library does not have the ssh features to support it.

If you try to pull or push from a git ssh repo in Visual Studio, you will see the following error message:

An error occurred. Detailed message: An error was raised by libgit2. Category = Net (Error).
This transport isn’t implemented. Sorry

After searching online, I found out that this issue is not caused by Microsoft’s Visual Studio. It is the responsibility of libgit2. To work around that issue, you can update the url by updating the config file. To do that, find your .git folder (it might be hidden) and inside that folder, open the config file using notepad. Find the url and you will see that it starts with “git…”. Now find the https url and update it. Now close the config file and you should be able to do all the git operations inside Visual Studio.

I hope you find this tip useful.