Posterous
Rob is using Posterous to post everything online. Shouldn't you?
Img_2722__modified__thumb
 

The Havers Of Rob Sharp

Being the lifestream of a Scottish geek living and working in Sydney.

Mixing rspec and mislav's will_paginate plugin

I didn't find the solution to using will_paginate in rpsec'd views anywhere, so here it is for anyone else searching for the same.

The solution is to build mock ActiveRecord models as part of an array, which will get you most of the way there. Then you can either the mock in the will_paginate methods, or you can simply call the paginate method on the array itself, as the plugin extends the Array class.

The code looks a bit like this:

describe "/items/index.html.erb" do

  before(:each) do
    @items = [
      stub_model(Item,
        :name => "value for name",
        :description => "value for description"
      ),
      stub_model(Item,
        :name => "value for name",
        :description => "value for description"
      )
    ]
    assigns[:items] = @items.paginate({:page => 1, :per_page => 30})
  end

 

Filed under  //   rspec   ruby   testing   will_paginate  
Posted January 11, 2010
// 0 Comments

Formica: Affordable, open source swarm robotics

Swarm robotics is a hot research area. Various algorithms for distributed problem solving are being developed, particularly in simulations. The focus is on complex, emergent behaviour arising from the local interactions of individuals following simple rules.

Posted January 10, 2010
// 0 Comments

Snow Crash

"The winter whiteout conditions affecting the UK are clearly visible in this striking image received by the University of Dundee Satellite Receiving Station. It shows almost all of the country covered in a white blanket of snow and ice. Photo by NEODAAS/University of Dundee."

Posted January 7, 2010
// 0 Comments

People don't want their lives fixed.

Posted January 6, 2010
// 0 Comments

"Lost" Last Supper Promotional Photo From ABC Clues - Speakeasy - WSJ

Posted January 5, 2010
// 0 Comments

Virtual Richard M. Stallman Meme

 

Joining in… Planet Ubuntu Virtual Richard M. Stallman meme

Here’s my Ubuntu Karmic on my Asus EEE

 

robsharp@bamboo:~$ vrms

No non-free or contrib packages installed on bamboo!  rms would be proud.

 

At one point or another I may have installed and removed nonfree software, such as Skype, but this little gem provides a post apt-get remove purge, which resulted in my clean sheet! I'm such a purist :-p

dpkg -l |awk ‘/^rc/ {print $2}’ |xargs sudo dpkg --purge

 

Posted December 10, 2009
// 0 Comments

The result of my recent #threadless splurge

Posted December 8, 2009
// 0 Comments

The engineers build a christmas tree

Posted December 8, 2009
// 2 Comments

Climate Change Deniers vs The Consensus

A wonderful visualisation of the rather confusing and conflicting arguments surrounding climate change.

Posted December 8, 2009
// 0 Comments

Thanks, domain.com.au. That's really helpful.

Posted November 26, 2009
// 1 Comment