It doesn''t seem like my controller specs are calling my middleware on requests. Has anyone figured out a good way to test middlware with rspec? I''m thinking something like rails'' rails/actionpack/test/controller/session/mem_cache_store_test.rb but with rspec... any thoughts? Thanks! Best, Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090922/2c6fabef/attachment.html>
On Tue, Sep 22, 2009 at 12:22 AM, Aaron Gibralter <aaron.gibralter at gmail.com> wrote:> It doesn''t seem like my controller specs are calling my middleware on > requests. Has anyone figured out a good way to test middlware with rspec?Rack::Test is your friend: http://github.com/brynary/rack-test If you Google it, there''s a fair amount of lore out there already on using it in various contexts. (And yes, the methods it provides work just as well in RSpec.) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org
Ah ok. I tried that, but I can''t seem to figure out what to use for the def app ... end method in my spec though. The app is my Rails app... for now I have something like: http://www.pastie.org/625791 I can get the dummy_app to work, but now I''m trying to figure out how to use my Rails app. I''ll keep playing around and see if I can come up with anything. Thanks! -Aaron --------- Rack::Test is your friend: http://github.com/brynary/rack-test If you Google it, there''s a fair amount of lore out there already on using it in various contexts. (And yes, the methods it provides work just as well in RSpec.) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090922/9c43f394/attachment.html>
On Tue, Sep 22, 2009 at 8:24 AM, Aaron Gibralter <aaron.gibralter at gmail.com> wrote:> > I can get the dummy_app to work, but now I''m trying to figure out how to use > my Rails app. I''ll keep playing around and see if I can come up with > anything.It sounds like you''re trying to do integration testing (all the pieces of the system working together) instead of unit testing (testing each piece of the system). My suggestion would be to let your middleware specs test your middleware, and your controller specs test just the controller. You can set up stubs or tweak the request to feed it whatever this middleware is supposed to do. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org
Ah true, I definitely just realized that. The reason I was trying to use rails though was to provide endpoints for the calls passing through my middleware. For that though, I can just use the dummy app. Thank you! On Tue, Sep 22, 2009 at 10:25 AM, Stephen Eley <sfeley at gmail.com> wrote:> On Tue, Sep 22, 2009 at 8:24 AM, Aaron Gibralter > <aaron.gibralter at gmail.com> wrote: > > > > I can get the dummy_app to work, but now I''m trying to figure out how to > use > > my Rails app. I''ll keep playing around and see if I can come up with > > anything. > > It sounds like you''re trying to do integration testing (all the pieces > of the system working together) instead of unit testing (testing each > piece of the system). My suggestion would be to let your middleware > specs test your middleware, and your controller specs test just the > controller. You can set up stubs or tweak the request to feed it > whatever this middleware is supposed to do. > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090922/ddb80b79/attachment.html>
Maybe Matching Threads
- RecordNotFound bubbling thru to cucumber
- Can't run specs after upgrading gems... get 0 tests, 0 assertions...
- Verifying some understanding about manipulating DB data in before/after callbacks in RSpec
- spec-ing private methods?
- [RAILS] - 2.3.3 creating a sea of red