Last Updated: February 25, 2016
· jodosha

CouchRest::Model views errors with RSpec

The latest CouchRest::Model Views (on 2.0.0.beta) aren't implicitly resolved when should is invoked on them.

For instance if I do:

dossier.documents.should be_empty

Dossier's documents at this point is not an instance of Array but of CouchRest::Model::Designs::View that means it doesn't behave like you might expect. One solution is to call all before of should, but I didn't liked the idea of changing tons of specs in this way.

I decided to add a little, dirty trick here:

CouchRest::Model::Designs::View.class_eval do
  def should(*args)