Testing multiple apps with rspec

129 views
Skip to first unread message

pmcg

unread,
Feb 3, 2011, 4:53:28 AM2/3/11
to sinatrarb
Hello
Has anyone got a link to a real or sample sinatra application that has
mutiple applications which are configured with Rack map calls in a
rackup file ?

I have set up a tiny example which can be found @ https://gist.github.com/336211
where i can run make request on both applications when i start with
shotgun, but when i try to test using rspec my tests are failing with
the following
expected ok? to return true, got false
/home/pmcgrathadmin/rubyinv/sinwith2/spec/web_application_spec.rb:
22:in `block (3 levels) in <top (required)>'

I have managed to test a classic style application with rspec, so just
trying to understand how i cater for multiple applications

Thanks in advance
Pat

Tanner Burson

unread,
Feb 3, 2011, 11:21:41 AM2/3/11
to sina...@googlegroups.com
How are you setting up your rspec class? Are you creating an instance of only one of your application classes?

The way I've handled this in the past (I don't have any sample code handy right this second, but if this doesn't solve it I'll try and knock some out this afternoon), is simply to test each of my Sinatra::Base subclasses in isolation. Just create an instance of one of them using Rack::Test, test it. Then write a different spec for your other class.

--Tanner


--
You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To post to this group, send email to sina...@googlegroups.com.
To unsubscribe from this group, send email to sinatrarb+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sinatrarb?hl=en.




--
===Tanner Burson===
tanner...@gmail.com
http://www.tannerburson.com

pmcg

unread,
Feb 3, 2011, 11:41:24 AM2/3/11
to sinatrarb
Aplogies i linked to the wrong gist correct one is here https://gist.github.com/809216
which includes the test cases where they are in seperate files and i
try to test each application in isolation as Tanner suggested


Pat
> > sinatrarb+...@googlegroups.com<sinatrarb%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/sinatrarb?hl=en.
>
> --
> ===Tanner Burson===
> tanner.bur...@gmail.comhttp://www.tannerburson.com

Tanner Burson

unread,
Feb 3, 2011, 12:17:59 PM2/3/11
to sina...@googlegroups.com
Okay here's the issue. Your app isn't Sinatra::Application, it's ProductInfo::Service or ProductInfo::WebApplication

def app
Sinatra::Application
end

Should be

def app
ProductInfo::Service
end

Hope that helps.

--Tanner

To unsubscribe from this group, send email to sinatrarb+...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/sinatrarb?hl=en.

pmcg

unread,
Feb 3, 2011, 1:48:31 PM2/3/11
to sinatrarb
Tanner,
Perfect, that that sorted it for me. I have updated the gist @
https://gist.github.com/809216

Thanks
Pat
> > <sinatrarb%2Bunsu...@googlegroups.com<sinatrarb%252Buns...@googlegroups.com>
Reply all
Reply to author
Forward
0 new messages