[rspec-users] Rspec Sinatra and Activerecord

Jay McGaffigan hooligan495 at gmail.com
Tue May 25 13:33:49 EDT 2010


I have a sinatra app that I've integrated with Activerecord that I am
trying to write some specs for.

I have a simple spec where I am essentially getting "all" rows from my
model table.

However I'd like to stub out the call.

so.. in my spec's before block I try to do something like:


in my spec I do :

 it "should retreive all ids" do
    get "map/site1"

and my spec keeps failing on IdMap.should_receive....
It complains that it cannot connect to the database.

If I swap in mocha and do IdMap.expect....  it works.

I'd prefer to stick with Rspec's mocking and stubbing library in this
case tho... I was wondering if anyone could shed some light on whether
or not I am doing somethign wrong?


More information about the rspec-users mailing list