I’m pretty sure this has probably been discussed before.
I’m using couchdb (couchrest_model)
When speccing my controller i want to set expectations that im calling
my couch views correctly.
The query interface has recently been updated to work very similar to
ARel
I could use stub_chain, but that doesn’t allow me to check the params
being passes to the calls other than the last.
I could also create a wrapper method on my Exam model that is called
from the controller with hash params,
however that just shifts the problem, I then have to check the
expections in the model spec instead.
Suggestions on how best to go about that would be appreciated.
On Tue, Nov 08, 2011 at 12:36:22AM +0000, Justin Ko wrote:
I’m using couchdb (couchrest_model)
I set an expectation on that easily like so:
I could also create a wrapper method on my Exam model that is called from
the controller with hash params, http://rubyforge.org/mailman/listinfo/rspec-users
}
Heh, that’s magic.
So maybe it’s just better to create the documents in couch…
I’m happy to do that, I just figured it would drastically effect
performance of the tests.
The query interface has recently been updated to work very similar to ARel
with(:startkey => [@exam1.created_at],:endkey => [‘0’],:limit => 2).
Suggestions on how best to go about that would be appreciated.
double(‘startkey’).tap {|startkey|
)
LOL, this is the ugliest code I’ve written all year. You’d might want to use
variables for readability:
…or even wrap this Exam thing in an abstraction layer? Can anyone else hear
the tests screaming?
Personally, I wouldn’t mock this code at all. It’s a data retrieval
method, let it hit CouchDB (abstracted or not).
Heh, that’s magic.
So maybe it’s just better to create the documents in couch…
I’m happy to do that, I just figured it would drastically effect performance of
the tests.
Create the docs and test it in Isolation. If you’re worried about
performance, mock the abstracted method everywhere else.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.