+ R1: A good test suite increases confidence that code changes won't cause
+ unexpected side effects without being noticed.
+ R2: Tests reduce the cost of structural changes in later stages of a project
+ because fewer bugs sneak into a system unnoticed.
- R3: Brittle tests can increase the cost of refactoring if they focus on
# Build script for Jenkins. This builds the checked out code and will deploy it if the commit came from | |
# an environment defined by the DeployEnvironment class. | |
# | |
# Scroll down to the bottom of this script to trace how it works. | |
require 'open-uri' | |
class StandardOutLogger | |
# Logs a message to standard out in red | |
# | |
# @param [ String ] msg The message to log |
mike@rbci:~$ psql -U postgres | |
psql (9.0.3) | |
Type "help" for help. | |
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0'; | |
UPDATE 1 | |
postgres=# \c template0 | |
You are now connected to database "template0". | |
template0=# update pg_database set datistemplate = FALSE where datname = 'template1'; | |
UPDATE 1 |
// Media Queries in Sass 3.2 | |
// | |
// These mixins make media queries a breeze with Sass. | |
// The media queries from mobile up until desktop all | |
// trigger at different points along the way | |
// | |
// And important point to remember is that and width | |
// over the portrait width is considered to be part of the | |
// landscape width. This allows us to capture widths of devices | |
// that might not fit the dimensions exactly. This means the break |
class RecruitmentPipeline | |
end | |
# Stage is a progression or step on a candidate's job application. | |
# It represents the state the application is in and offers several | |
# statistic on the effectiveness of consultant at this stage. | |
# | |
# For example, Stage 1 might be AppliedStage, or NewStage | |
# depending on whether candidate applied himself or consultant | |
# selected him. |
-- PostgreSQL 9.2 beta (for the new JSON datatype) | |
-- You can actually use an earlier version and a TEXT type too | |
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8 | |
-- JSON Types need to be mapped into corresponding PG types | |
-- | |
-- Number => INT or DOUBLE PRECISION | |
-- String => TEXT |
Corey Haines gave his Fast Tests talk at the Golden Gate Ruby Conference 2011 (http://confreaks.net/videos/641-gogaruco2011-fast-rails-tests), here's my feedback on it.
So first up, I think it's very interesting to see another take on how to speed up Rails testing. There's been a focus on it for a couple of years now with various solutions coming for it. From running tests in parallel, to tweaking the filesystem for faster access. Corey Haines take on it is that we should isolate ourselves from the framework that Rails provides and do as much as possible in plain Ruby objects and modules. In his talk he shows how he has been able to massively improve the runtime of his tests by implementing this.
I think it is a logical next step to the current that has been in the community for a while where we have been debating how to improve the design of Rails applications.
class ActionDispatch::Routing::Mapper | |
def draw(routes_name) | |
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb"))) | |
end | |
end | |
BCX::Application.routes.draw do | |
draw :api | |
draw :account | |
draw :session |
require 'rubygems' | |
require 'wirble' | |
require 'hirb' | |
require 'ap' | |
require 'pp' | |
Wirble.init | |
Wirble.colorize | |
Hirb.enable |
class User < ActiveRecord::Base | |
attr_accessible :name | |
has_many :admin_memberships, class_name: "Membership", conditions: {role: 'admin'} | |
has_many :editor_memberships, class_name: "Membership", conditions: {role: 'editor'} | |
def admin? | |
admin_memberships.exists? | |
end |