tommy
  • photography
  • projects
  • archive
  • Cleaner RSpec Controller Specs

    RSpec, dev, ruby, testing May 19, 2011

    Testing is an important part of software development. Having a solid test suite allows you to develop more confidently – it enables you to make large refactorings without fear of unintended consequences. I test almost all the code I write.

    Recently, I found a bug that allowed users to see ‘inactive’ products; so I wrote a test to prevent that. I’ve seen lots of specs that test active products like so:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    it "scopes products to active and available" do
        not_active = Factory(:product, :active => false)
        not_available = Factory(:product, :available => false)
        active_available = Factory(:product, :active => true, :available => true)
        get :index
        assigns(:products).should_not include(not_active)
        assigns(:products).should_not include(not_available)
        assigns(:products).should include(active_available)
    end
    

    Tests like this are wordy and can lead to a ton of factoried objects. There’s got to be a better way!!

    Read on →
  • Berkeley Asian Business Conference

    poverty, wikipedia Apr 3, 2011

    The most anti-poverty tool the world has ever seen is Wikipedia.
    Peter Schwartz

  • Malaysian Flip Flops

    Facebook, Google, Malaysia Feb 4, 2011

    I just got back from Port Dickson with Mike, his wife Shux, and her entire family for Chinese New Year. I was really impressed with the counterfeit products you can buy in the market.. these flip flops look just like my real Facebook flip flops.

  • Singaporean Slinging

    Singapore Oct 28, 2010

    The Raffles Hotel is known for its Singapore Sling, but I was most impressed by the fans! No rotary fan blades here… just hand fans and a pushrod.

  • Johor Bahru

    Malaysia, photography Oct 23, 2010

    This weekend I headed up to Johor Bahru with my coworkers on Viki. Going to Malaysia seems akin to a trip to Canada for a Mainer; except, it turns out to be a country where you need proper papers. I was stopped at the Singaporean border for forgetting my entry visa in my apartment… whoops. Fortunately, Singaporeans are accommodating so they checked my numbers and I was good to go.

    Crossing borders is hard work… this is a picture of Sunjin saying he’s hungry and we should find some food & beer. (He doesn’t talk too much)

    Read on →
← Older Newer →
  • sillylogger
  • sillylogger
  • A place for me to put photography and work that is too long for Twitter.