Go is an extremely clean and fun language to work with and has a bunch of handy, modular, well documented packages out of the box. We can easily build a small web app using pure Go for handler functions, the net/http library for routing and serving and mgo as a MongoDB driver. The simple Go … Continue reading A Simple Go Web App on Heroku with MongoDB on MongoHQ
When we think of interfaces, as traditional object-oriented programmers, the words 'abstract' or 'implements' come to mind and the example of the Shape Interface with the Rectangle and Triangle classes materialises before us; or the Animal interface with a Dog and Cat class mulling around. Go thinks differently and hence I take a different (and probably … Continue reading Go Interfaces and Quacking
Welcome to the world of mocks and stubs using minitest-rails. We see various helpful gems that help in mocking and stubbing.
Mocks and stubs are not new concepts that have been introduced in minitest. If you want to get detailed understanding about what are mocks and stubs you should read mocks aren’t stubs written by Martin Fowler. To achieve mocking and stubbing in minitest-rails you don’t need to include any separate gem like rspec-mocks in rspec. Let see how to do work with mocks and stubs in minitest then check what are gems available to add extra functionality.
Stubbing a method means, set a pre-defined return value of a method in test-case. Let’s check how to do method stubbing in minitest:
In this example, I stub
foo and check what would be the output of
new_method. As matter of fact it won’t call actual
foo method instead it calls stub
foo method. Now that we have seen how to stub and instance method, let check how to stub on…
View original post 275 more words
Read details about Bundler configurations, settings and paths. Learn about various Ruby constructs through bundler code.
Note: I am currently using ruby-2.1.0 with rvm-1.25.13 and for bundler code, i have used relative path to bundler. On my system, Bundler absolute path is $HOME/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.0. You can have different path based on your preferences.
In my previous post, we have learned how bundler gets started and how it executes various commands (‘install’, ‘exec’) with the help ‘thor’ gem ‘start’ function. We have seen the code below inside the install function of ‘bundler/cli’.
Bundler.definition is defined inside the ‘lib/bundler.rb’ with context as self (i.e. Bundler itself) and it initializes ‘Bundler::Definition’ that can is inside ‘lib/bundler/definition.rb’. I have pasted the code of ‘Bundler.definition’ below.
Bundler.definition (unlock variable)
The variable unlock has one of the three values: nil , true and a hash containing the gem names and gem sources.
While executing command `bundle install`, unlock is not passed and has a value nil but while updating all gems with…
View original post 480 more words
If history is anything to go by it seems inevitable that a new language will dominate the next decade. A new language will also need to solve problems that matter to this expanded world and that the existing languages will be slow to provide (or find impossible to provide). Could that new language be Go?