Category Archive: rspec

Apr 24

DRY your RSpecs

Inspired by reading DRY your Scopes… Sometimes I find that I can write a bunch of tedious specs in a simplified manner described below. It started innocently enough. As a certain set of features were growing, I found that I was writing repetitive tests like this: context ‘specialty patient section’ do it(‘has specialty patient’) { …

Continue reading »

Apr 06

RSpec, Mongo and Database Cleaner

This is kinda obvious, once you see it… But I’d figure it might help someone, someday. I wanted to create a document one time, so I put it in the before :all block. Yet, in the “it should” block, the document was gone, spec failed. If I changed to a before :each block, the spec …

Continue reading »

Apr 02

Lets in RSpecs Can Be Blech

Maybe it is just me, but I had suspected some weirdness here and there from using the fancy “let(:var_sym)” syntax. The trusty RSpec book says: The first call to let( ) defines a memoized output( ) method that returns a double object. Memoized means that the first time the method is invoked, the return value …

Continue reading »

May 11

You Don’t Always Have to Follow “The” Rules

RSpec for an API

A user was asking the following on the Agile Modeling list: What experience does anyone have about standards for stories written for non-UI components? I’m working with a proxy PO who feels the standard story format (As a <user> I want to <activity> so that <purpose>) simply won’t work for something that doesn’t have a …

Continue reading »

Apr 20

Factory Girl and MongoMapper

Factory Folder

You were probably hoping for some Rosey the Riveter poster… Instead, I am going to extend my small MongoMapper example to include Factory Girl. The steps are pretty simple: Go here to install… Create your factories Use the factories in Cucumber/RSpec Factory Construction I created a new “factories” folder under the spec folder: The factories …

Continue reading »

Apr 20

Cucumber, RSpec, MongoMapper, Git, Oh My!

Commit History

Nick left a question on my many-to-many associations post. He wanted to know more about sorting by date and querying… So I decided to (over achieve and) show how I would approach that as if I were adding a new feature: Adding a “date” key field and an index Using Cucumber to drive the new …

Continue reading »