William Gibson on ‘Zero History’ Interview

I listened to this on Sunday morning over a few nice coffees. Super interview… well worth the listen.

Roman Numerals Elixir Kata

A fun little test driven kata which will introduce you to the basics of elixir.

A rule I try to follow for this is to try and keep my solution less than 20 lines of code.

Devlog: Rails Testing

Completed the Rails Testing for zombies courses on CodeSchool tonight.

I liked it, I always found starting a new rails app always triggered my testing OCD and it was nice to get an insight into the strategies one can take to test a rails app without overdoing it.

The course covers how to unit test and integration test your rails app with fixtures using TestUnit, so you are given a good idea of the tools at your disposal out of the box. As a well as that you are introduced to other popular testing gems which make your life easier such as Shoulda, Capybara and FactoryGirl. I will touch on each of there briefly to give you a taste of what they are all about…

During the Unit Testing section you are introduced to Shoulda gem which is described as an alternative syntax that is easy on the fingers and the eyes.

1
2
3
4
class UserTest < Test::Unit::TestCase
  should have_many(:posts)
  should_not allow_value("blah").for(:email)
end

As the course starts to dig into integration testing you are also introduced to Capybara which provides a interaction based DSL for defining your integration tests that supports multiple drivers. Capybara tests when executing act like a headless browser of sorts giving you more control over the interactions with your site or api, following redirects more naturally for example which is something not handles by vanilla rails integration tests so well.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 describe "the signin process", :type => :feature do
  before :each do
    User.make(:email => 'user@example.com', :password => 'password')
  end

  it "signs me in" do
    visit '/sessions/new'
    within("#session") do
      fill_in 'Email', :with => 'user@example.com'
      fill_in 'Password', :with => 'password'
    end
    click_button 'Sign in'
    expect(page).to have_content 'Success'
  end
end

Lastly you are introduced to FactoryGirl, which is an alternative to using the built in test fixtures provided by rails out of the box.

Read on →

Integrated Tests Are a Scam

Found this gem in a tweet from @david_whitney, and as he says the title is trolly but none the less is an excellent talk on automated testing.

Integrations Tests Lead to Bad Design

  • An interesting point is made (and I am paraphrasing) that the more integration tests we have the less design feedback we get, leading to sloppy design as we don’t feel the same feedback & design pressure…

What Failed and Where?

  • Integration tests may highlight failures, and the name of the test may go a long way to saying what failed, but pin pointing the actual location and reason for the failure is often lost in the generalization of the test itself.
Read on →

HTTP Status Code Decision Diagram

The best HTTP Status Code decision diagram I have seen to date. Source: https://raw.githubusercontent.com/for-GET/http-decision-diagram/master/httpdd.png