Suffix Suffix

Simple getters in Backbone.js

Posted on Nov 24th @ Home

There is an easy way to get your Backbone.js model attributes: person = new Person({firstName: "John", lastName: "Doe"}); person.get('firstName'); Overriding getters This is all great if all you need is a simple getter but you quickly want to get something more powerfull. What if you want to show the persons full name, his first and last name combined? You could simply concatenate both attributes in your template but that gets annoying quickly. What we want is a convienience fun...

Rake and multiple arguments

Posted on Oct 3rd @ Home

Rake has a new syntax for passing arguments. In the old version it looked something like this: task :hello, :first_name, :last_name, :needs => :environment do |t, args| puts "Hello #{first_name} #{last_name}" end Running this task in a newer version of Rake shows a depreciation warning: WARNING: 'task :t, arg, :needs => [deps]' is deprecated. Please use 'task :t, [args] => [deps]' instead. Luckily it's easy to switch to the newer syntax: task :hello, [:first_...

Rails 3.1 asset pipeline in production

Posted on Aug 5th @ Home

The asset pipeline is probably one of the biggest additions in the upcoming 3.1 release of Ruby on Rails. It's a framework to minify and compress JavaScript and CSS code. The asset pipeline pre-minifies and pre-compresses all your JavaScript code in a signle file, the same goes for your stylesheets. This results in smaller files and less HTTP requests, meaining faster applications! The asset pipeline is enabled by default but will look a little strange if you are migrating from an older ve...

Sinatra view tests with Capybara & HAML

Posted on May 19th @ Baltimore

Ever seen something like this in a Capybara view spec? visit('/') page.has_css?('tr.foo') Capybara simulates user behavior, it will act like if a user is visiting the page and interact with it. For acceptance testing this is just fine. It will call the controller and render the page, full stack, and it's probably what you want. Isolation testing Sometimes, however, you do not want to test the full stack. Sometimes you want to test in isolation, only testing your view with...