Category Archives: Uncategorized

My Journey Down the Ruby Railroad

Hi everyone. It’s been nearly 8 years since I first learned Ruby. I did so while walking my firstborn daughter in a front-pack for miles every evening while listening to ruby podcasts. Walking her in the pack was the only thing that would keep her from crying. Watching Ruby podcast similarly kept me from crying. At least I was learning something new during the challenge of being a first-time dad running on virtually no sleep.

Those podcasts did not go to waste. They led me to my second software engineering job at a company called Within3 where I got to use Ruby in a work environment for the first time. It was an amazing experience that ultimately brought me to where I work now as a Senior Engineering Manager at Stitch Fix.

And all of this began with the simple decision to learn a new programming language.

As I continue my journey down the Ruby Railroad, I’m starting a side venture as a blogger on Medium. Most of my posts here will be cross-posts to articles I write on Medium. But I might still add original work here from time to time.

To follow along, my social media sites are below. They are in their infancy, but I’m excited to see how they evolve over time.

Please consider following any of these accounts if interested! And stay tuned for more content as the weeks and years go by.

Pete

Command Line Recipes À la Stitch Fix

Here is a list of command line recipes that make day to day life a little easier at Stitch Fix.

http://technology.stitchfix.com/blog/2015/04/09/stitch-fix-heart-unix/

Maybe you will find some of these useful for projects you are working on 🙂

Color Rspec Output for All Projects

Ran into an issue today where I wanted rspec to use color output regardless of whether or not the project had it set up in the .rspec or spec_helper.rb files.

A super simple way to do this is to update your .bash_profile and override the rspec command with the colour switch:

vi ~/.bash_profile

Add the following to .bash_profile and save:

alias rspec='rspec --colour'

Reload the file:

source ~/.bash_profile

And you should be all set! Just run rspec as you normally would and the colour switch will be added automatically via the alias.

Basic Controller Rspecs

MyWayOnRails

Suppose the following method is there in the controller

def new
  @post = Post.new
end

For this the corresponding spec will be as follows

describe "GET #new" do
  it "creates new instance of post" do
    get :new
    assigns(:post).should be_a_new(Post)
  end
end

In the above code “get :new” line will get the new path of the controller and execute the corresponding method described in the controller. So that particular statement is very important for execution of the method and comparison of the output in the test.

View original post 458 more words