Telling a good story – Rspec stories from the trenches

15 Aug

I’ve been developing multiple systems using Rspec stories for a little while now. There are a lot of great resources to get you started with a taste of what you can do with stories. Some of the resources I found useful where:

However once I had understood the basic idea I struggled to find practical examples and general guidance on writing real stories. So I’ve collected some of the lessons I’ve learnt along the way with story examples taken from real systems and how I’ve improved them as I learnt. Most examples are from web based applications.

(more…)

Ruby/Rails interview questions

25 Jul

I’ve recently been helping interview some ruby/rails developers. I searched the web for some inspiration but I could not find any example questions that had real depth to them. I like my questions to be a point of discussion rather than one word answers. Most importantly I want a wide enough scope to let those talented individuals shine through. So here are some of the questions I’ve been trying out recently.

(more…)

Rspec-rails mock_model helper for the RR test double framework

9 Jul

Rspec-rails is a rails plugin which brings the Rspec Ruby Behaviour Driven Development framework to rails along with some rails specific helpers. One of these hugely useful helper functions is:

mock_model(model_class, options_and_stubs = {})

This creates a mock object with the common methods stubbed out. It also allows you to specify other methods you want to stub.
(more…)

Textmate bundle for RR test double framework

7 Jul

A simple Textmate bundle for  RR the Ruby test double framework.  You can read about RR at http://github.com/btakita/rr/tree/master and look through the latest rdocs at Rubypub

Install with Git

(what on earth is Git…)

  1. Run this:
  2. mkdir -p ~/Library/Application\ Support/TextMate/Bundles/
    cd ~/Library/Application\ Support/TextMate/Bundles/
    git clone git://github.com/josephwilk/rr-tmbundle.git  rr.tmbundle
  3. Reload bundles in Textmate
  4. Enjoy!

Rspec Stories – Keeping Steps Dry

30 Apr

When using Rspec stories you have plain text stories which we call the ‘story’ file and the ‘story steps’ file that maps the plain text story to programmatic code. Generally you end up with your story files not being DRY. This is not a worry, your stories are the domain specific languages detailing your acceptance/integration tests. Its like saying that your Rails Models are not DRY because they repeat lots of 'has_one'!
(more…)

JavaScript Acting as a Robotic Agent

23 Feb

We can think of JavaScript running within a clients browser as a robotic agent. It has an environment in which it can sense things. The ability to look at the environment and make decisions based on plans.

clientagent.JPG

So whys that useful, well why is a robot useful? You can produce many different complex plans and give them to the robot and forget about it while it does the work potentially over and over again. If we are really lucky the robot can demonstrate some intelligence and deal with uncertainty.

Well I tried out a small part of this idea to build a server side service which delivered plans in JavaScript to the client. The JavaScript planning agent followed the plans. Its not a intelligent robot but this is just a prototype. The plans where focused on validation conditions that a user needed to get through to post a form.

(more…)

Rails Admins Plugins Review

14 Feb

A brief examination of some of the major Admin plugins for rails.

  • Lipsiaadmin
  • AutoAdmin
  • ActiveScaffold
  • Hobo
  • Streamlined

(more…)

Automatic Admin Systems – Semantics with Rails & Django

18 Jan

The Magically Appearing Admin

Web developers using an MVC framework produce their websites playing with their models, views and controllers. Then by adding a few lines of magic an admin system appears which allows users to add/edit/delete/view/search their models.

Examples:
Django’s Magic Admin (Also NewFormsAdmin – a branch of Django focused on making it easier to customise auto-admin)
Ruby on rails Plugins:

(more…)

Latent Semantic Analysis in Python

19 Dec

Latent Semantic Analysis (LSA) is a mathematical method that tries to bring out latent relationships within a collection of documents. Rather than looking at each document isolated from the others it looks at all the documents as a whole and the terms within them to identify relationships.

An example of LSA:
Using a search engine search for “sand“.

Documents are returned which do not contain the search term “sand” but contains terms like “beach”.

LSA has identified a latent relationship, “sand” is semantically close to “beach”.

There are some very good papers which describing LSA in detail:

This is an implementation of LSA in Python (2.4+). Thanks to scipy its rather simple!

(more…)

Building a Vector Space Search Engine in Python

27 Nov

A vector space search involves converting documents into vectors. Each dimension within the vectors represents a term. If a document contains that term then the value within the vector is greater than zero.

Here is an implementation of Vector space searching using python (2.4+). (more…)