home

Boost Blog

Archive for September, 2009

September 15th, 2009

What should break the test?

Posted by jeremy on September 15th, 2009

I recently came across FakeFS, which sounds like a great idea for helping to test file functions. However, I did pick up on the following off the website:

[...] it means replacing our mkdir call with a call to mkdir_p won’t break our tests. Because, really, it shouldn’t.

Now I understand that in the context of the example given, mkdir and mkdir_p should do the same thing. But mkdir and mkdir_p do perform different operations, and the tests should break if mkdir_p is changed to mkdir. If you change mkdir_p to mkdir and your passing tests don’t fail then your tests aren’t correct.

Tags: ruby, tdd
Posted in: Development
No Comments
 
September 11th, 2009

Squirrel and the custom nut matcher

Posted by jeremy on September 11th, 2009

I recently found squirrel, and I wanted to use it for a project we’re working on to simplify some complex finder statements. Squirrel allows turning something like this:

Task.find(:all,
  :conditions => [
    'active = ? and (updated_at > cache_version or cache_version IS NULL)', true
  ]
)

into:

Task.find(:all) do
  active == true
  any do
    updated_at > cache_version
    cache_version.nil?
  end
end

The problem is testing

Then I ran into a serious problem – how to test this piece of code using rspec? Here was my first attempt: more »

Tags: rails, rspec, ruby, tdd
Posted in: Development, Ruby on Rails
2 Comments
 
  • Categories

    • Agile (3)
    • Cool tools (5)
    • Curriculum (2)
    • Design (6)
    • Development (14)
    • Drupal (1)
    • e-Learning (6)
    • Publishing (1)
    • Random thoughts (2)
    • Ruby on Rails (8)
    • Social media (6)
    • Usabilty (2)
  • Archives

    • July 2010 (6)
    • June 2010 (2)
    • April 2010 (1)
    • March 2010 (1)
    • February 2010 (1)
    • January 2010 (3)
    • December 2009 (1)
    • November 2009 (1)
    • October 2009 (4)
    • September 2009 (2)
    • August 2009 (3)
    • July 2009 (6)
    • June 2009 (1)
    • May 2009 (1)
    • April 2009 (2)
    • March 2009 (1)
  • Boost Loves Design

    • I love Typography
    • IntuitionHQ | easy website usability
    • OMG It even has a watermark
    • Follow me on Twitter
    © Boost Limited.
    All rights reserved.
    CONTACT US
    info@boost.co.nz
    tel. (04) 939 0062
    fax. (04) 939 0063

    Level 6, 175 Victoria Street
    PO Box 11504, Wellington
    New Zealand