Categories
Rails rspec Ruby

“You have to declare the controller name in controller specs”

For ages I’ve been getting an intermittent problem with RSpec, where occasionally I’d see the following error on a model spec:

You have to declare the controller name in controller specs. For example:
describe "The ExampleController" do
controller_name "example" #invokes the ExampleController
end

The problem seemed to depend on which order the specs were run in, and for rake it could be avoided by removing --loadby mtime --reverse from spec.opts. It was a real pain with autotest though, and today (my original plan of “wait for RSpec 1.1 and hope it goes away” having failed) I finally got round to looking into it properly.

It seemed that the error was being triggered by the rather unpleasant code I wrote a while ago to simplify testing of model validation. Digging into the RSpec source to see what was happening, I found that that error message only gets returned when (as you’d expect) you don’t declare the controller name in a controller spec (specifically in an instance of Spec::Rails::Example::ControllerExampleGroup). The code that decides what type of example group to create lives in Spec::DSL::BehaviourFactory, and according to its specs, there are two methods it uses to figure out what type of spec it’s looking at:

it "should return a ModelExampleGroup when given :type => :model" do
...
it "should return a ModelExampleGroup when given :spec_path => '/blah/spec/models/'" do
...
it "should return a ModelExampleGroup when given :spec_path => '\\blah\\spec\\models\\' (windows format)" do
...
it "should favor the :type over the :spec_path" do
...

I began to suspect that the problem was caused by the fact that my specify_attributes method wasn’t declared in a file in spec/models, so I thought I’d try specifying the type explicitly. So instead of this:

describe "#{label} with all attributes set" do

I changed it to this:

describe "#{label} with all attributes set", :type => 'model' do

Sure enough, it worked! Not sure whether anyone else is likely to see the same problem (unless they’re foolish enough to use my validation spec code), but hopefully if you do, a Google search will bring up this post and it might point you in the right direction.

Categories
Uncategorized

Chocolate Type

Mmm…

Categories
web

BarcampLondon3

As you may have guessed from my other postings over the past few days, I spent the weekend at BarcampLondon3, at Google’s offices in Victoria, London.

This was the second Barcamp I’ve participated in (‘attended’ is probably too passive a word for a Barcamp), and was even better than BarcampBrighton in September. This was, of course, largely thanks to all the efforts of Ian and the other organisers, and to the wonderful hospitality shown by Google. From my own point of view, I think I also benefited from not going with a group of colleagues, which forced me to overcome my natural reticence and speak to people I didn’t know (it helps that the Barcamp crowd are a friendly bunch!)

If you have any geek tendencies and have never been to a Barcamp, I highly recommend it.

Oh, and as a footnote, I experimented with blogging some of the talks more-or-less as they happened. That’s why the posts were a bit rough, but at least they’re there – I still have notes from Agile2007 back in August that I haven’t got round to writing up.

My photos from the weekend are on flickr.

[tags]barcamp, barcamplondon3, google[/tags]

Categories
General nonsense

Lolwolves

From the meme collision department…

In ur villij

Ur seer

icanhaz lynching?

[tags]lolcats, werewolf, lolwolf, lolwolves[/tags]

Categories
General nonsense Rails

Rails Envy’s take on the werewolf question

This clip [MP3, 57s] from a Rails Envy podcast made me laugh. It’s referring to Charles Nutter’s recent musings on whether werewolf is killing the conference hackfest.

Incidentally, how often do you get the chance to Google for “nutter werewolf”?

[tags]rails envy, werewolf[/tags]

Categories
General nonsense

[BarcampLondon3] 101 Uses for an Index Card

I’d originally intended to present something about BDD, but the slides and demo never really came together so I didn’t really want to inflict them on people who could have gone to a better session. I was going to risk bad karma by not presenting at all (there were plenty of empty slots, so I don’t think I’d have been the only one).

At some point in the early hours of Sunday, trying to sleep in a very warm room where the lights kept randomly coming on, I thought of another idea – could a bunch of us come up with 101 uses for an index card (something I’ve been planning to try myself for a while)? It would be obvious from the title that it was just a bit of fun, but maybe ew might learn something along the way about the techniques that people used which used index cards in some way.

Unfortunately (I like to think purely because I posted the session on the board at lunchtime on Sunday!) only two people turned up, beating my record of four from BarcampBrighton. We did manage to get a third of the way though, coming up with 34 uses:

  1. CRC cards
  2. Shopping list
  3. Werewolf
  4. Release planning/User stories
  5. Enumerating the uses of an index card
  6. Taking notes
  7. Essential use cases
  8. Paper prototyping
  9. Bookmark
  10. Funnel for salt, sugar etc
  11. “Indexing stuff” (ie whatever they were originally designed for)
  12. Emergency business card
  13. Barcamp/unconference scheduling
  14. Playing 1001 Blank White Cards
  15. Inflicting paper cuts on an enemy
  16. Making an animation flip-book
  17. House of cards
  18. Making noises with bicycle spokes
  19. Drug pouches (I have no idea what this means!)
  20. Roaching
  21. Paper planes (although our test model was prone to nosedives)
  22. Cue cards
  23. Flash cards
  24. Postcard
  25. Beermat
  26. Recipes
  27. To-do lists
  28. Lighting fires
  29. Setting fire to, in order to satisfy the requirement to collect “fire” in a scavenger hunt
  30. Bulletin board advert
  31. Very simple origami
  32. Signage
  33. Action Man billboards
  34. Blocking CCTV cameras

Paul also added “toothpick”, via a Flickr comment.

PICT2381.MRW Some of the 101 uses of an index card

[tags]barcampbrighton3, indexcards, 101[/tags]

Categories
Apple

[BarcampLondon3] Obscure Mac Apps (Melinda & Martin)

  • KeyCue (€19.99 + VAT)
  • Caffeine (free) – prevents sleeping, display dimming etc
  • iStat menus (free) – also includes menubar clock like Magical
  • NameChanger (free) – bulk file renaming
  • Yojimbo ($39) – stores and tags web pages, documents etc (the actual content, not just a link). Also a web version.
  • Keyboard Cleaner (free) – disables keyboard
  • Audio Hijack Pro ($32) – record any system audio.
  • Bento – personal version of Filemaker
  • Picturesque ($20 shareware) – uses Core Image to do all sorts of cool image effects
  • XLD (free/OSS) – converts various lossless audio formats
  • ImageWell (free) – batch image editing (see also Skitch)
  • FreeDMG (free, unsurprisingly) – Simple disk image creation
  • ZapMac (free) – wacky speed-reading thing
  • Nocturne (free) – ‘night mode’ for working more comfortably in the dark
  • Remote Buddy (€19.99) – use Apple remote with any app, or for browsing files. Also allows you to use Wiimote via bluetooth.

[Update: it seems I was misinformed – Skitch is free too.]

[tags]barcamplondon3, mac, applications[/tags]

Categories
web Web 2.0

[BarcampLondon3] JQuery in 30 minutes (Simon Willison)

I didn’t take any notes, but JQuery looks pretty cool. Maybe even cooler than Prototype and Scriptaculous!

[tags]barcamplondon3, jquery, javascript, prototype, scriptaculous[/tags]

Categories
Uncategorized

[BarcampLondon3] How to Animate a Silly Walk (Cathy Jones)

This was a hands-on session playing with lo-fi flip-book animation, based on the techniques on Cathy’s blog. Here’s my very poor effort:

[tags]barcamplondon3, animation, silly walks[/tags]

Categories
Uncategorized

[BarcampLondon3] Creating a Lifestream with Yahoo Pipes (CristianoBetta)

It’s all here!

[tags]barcamplondon3, lifestream, yahoopipes[/tags]