Software creative always looking for a challenge

Posts Tagged: ruby

Stubbing without RSpec

In rspec you can typically call the stub method to stub something out. However, this method only works inside an example or  a before(:each) block. Try using rspec stubs anywhere else and you get the following error message

The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported.

What if you wanted to temporarily stub out one object inside a before(:all) (since you like those fast test, don’t you 😉 or globally for the entire test suite for say disabling image processing. How would you do that?

Simple, Ruby has this magic word called metaprogramming to rescue us.

Instead of doing:

Just do:

That is it. We just overwrote the definition of the process method for only this one image instance. No side-effect or stub-code leakage will occur here.

0idle: A marketplace where Event Organizers find Venues

Screen Shot 2013-09-11 at 2.23.28 PM

My roommate (Anton Kishchenko) and I started working on a marketplace to help event organizers find venues called 0idle. After initial market research, we received great feedback and decided to start building the product. I decided to start building it in Rails, since I have worked with it before, knowing that it is a great framework.
More…

Reborn: Simplicity and Focus

The Big Bang

As you may have noticed the site has a fresh new look now. But it is more than that, much more. I now have a more focused approach to the content and a simpler website to navigate through.

Many of my personal heroes — including the super heroes listed on the bottom — have an incredible sense of focus, which contributes in no small part to their success. I have been hearing about the need to focus a lot lately. More…