Spec Resourceful

Mar 2nd — 7:33 PM

I just committed a new plugin to GitHub called spec_resourceful. Well, sorta new. It’s actually a fork of a plugin I use all the time (make_resourceful) but with its scaffold generator generating specs with RSpec instead of Test::Unit. I also rewrote the scaffolding to fit my own aesthetic. Like, instead of using a form for :new and another almost identical one for :edit, I prefer using just one template (form.html.haml) and letting form_for do its magic. I also have a before_filter that redirects :create/:update requests with a params[:cancel] to the :index action. Not sure if anyone else out there would like it but I’m offering it to the world anyhow. :)

One thing I do think other people [who use RSpec] might like is the view spec helpers I wrote that help make those view specs less brittle. Instead of spec’ing a specific HTML element in a form you can just response.should allow_editing(@foo, :bar) and feel free to tweak your HTML with impunity knowing that you’ve spec’ed the behavior (that the user can edit @foo’s bar attribute) and not what HTML element you used to edit it. You can check them out at the GitHub repo. I’d love your feedback if you use this. Or if you don’t. Unless your name is Pratik and I already know what you’re going to say.

Filed under: plugins, rspec, rails

Leave a Comment

Lucky Sneaks is designed and managed by Lucky Sneaks
All content © Lucky Sneaks 2008
Lucky Sneaks is Lucky Sneaks