David Leal
2007-Jul-02 10:33 UTC
[rspec-users] Testing route globbing and limitations of get()
Hi everyone, I''m new to rails and also to rspec, but I tried to do my homework. To answer my questions, I searched this list''s archives, the Rails API, and Google, to no avail. Therefor, I''d be grateful if someone could point me in the right directions: 1) There doesn''t seem to be a counterpart to assert_recognizes in rspec. route_for() won''t work with route globbing (or will it?) So, how do I test route globbing? 2) Still using route globbing, if I do get ''/something/somewhere'' rspec will complain that it couldn''t find an action for ''/something/somewhere''. I suppose this is the correct behaviour, since we''re testing the controller, and not routing. However, since the controller action is a catchall, I must pass a path to it, or it won''t know what to do. If I try to specify the path using request.path = ''/something/somewhere'' get ''my_action_name'' the path comes out as ''/''. Can anyone instruct me on how to do this correctly? Cheers, -- David Leal -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070702/88d94b31/attachment.html
David Chelimsky
2007-Jul-02 12:51 UTC
[rspec-users] Testing route globbing and limitations of get()
On 7/2/07, David Leal <dgleal at gmail.com> wrote:> Hi everyone, > > I''m new to rails and also to rspec, but I tried to do my homework. To answer > my questions, I searched this list''s archives, the Rails API, and Google, to > no avail. Therefor, I''d be grateful if someone could point me in the right > directions: > > 1) There doesn''t seem to be a counterpart to assert_recognizes in rspec. > route_for() won''t work with route globbing (or will it?) So, how do I test > route globbing?For now you can use assert_recognizes.> > 2) Still using route globbing, if I do > > get ''/something/somewhere''You can use full paths like that in Rails integration testing (which is not yet supported in RSpec), but not in controllers. For controller examples, you just use the action name: describe SomethingController do it "should get me somewhere" do get ''somewhere'' ...> rspec will complain that it couldn''t find an action for > ''/something/somewhere''.That''s Rails complaining. RSpec is just the messenger.> I suppose this is the correct behaviour, since we''re > testing the controller, and not routing. However, since the controller > action is a catchall, I must pass a path to it, or it won''t know what to do. > If I try to specify the path using > > request.path = ''/something/somewhere'' > get ''my_action_name'' > > the path comes out as ''/''.This is all stuff related to Integration Testing, which I''m guessing is what you read about.> Can anyone instruct me on how to do this correctly?I think this should be answered by now. Write back if you still don''t understand. Cheers, David> > Cheers, > > -- > David Leal > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Leal
2007-Jul-02 15:31 UTC
[rspec-users] Testing route globbing and limitations of get()
Hi David, thanks for your reply. Regarding the last topic below, there''s something about which I''m not quite clear: The catchall method that I''m trying to test works by getting a path from the request object passed to it (during testing it''s a TestRequest object). If I understand correctly, there is no way to test this method without writing an integration test. But shouldn''t the request object honor the path I''ve set instead of resetting it? On 7/2/07, David Chelimsky <dchelimsky at gmail.com> wrote:> > > If I try to specify the path using > > > > request.path = ''/something/somewhere'' > > get ''my_action_name'' > > > > the path comes out as ''/''. > > This is all stuff related to Integration Testing, which I''m guessing > is what you read about. > > > Can anyone instruct me on how to do this correctly? > > I think this should be answered by now. Write back if you still don''t > understand. >-- David Leal 969 572 510 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070702/a7896cb2/attachment.html
David Chelimsky
2007-Jul-02 15:34 UTC
[rspec-users] Testing route globbing and limitations of get()
On 7/2/07, David Leal <dgleal at gmail.com> wrote:> Hi David, thanks for your reply. > > Regarding the last topic below, there''s something about which I''m not quite > clear: > > The catchall method that I''m trying to test works by getting a path from the > request object passed to it (during testing it''s a TestRequest object). If I > understand correctly, there is no way to test this method without writing an > integration test. But shouldn''t the request object honor the path I''ve set > instead of resetting it?I''ve never tried to do what you''re doing so I can''t answer from experience. What I can tell you is that the TestRequest object is part of Rails, not rspec, so you might have some good luck on the rails forums and mailing lists.> > > On 7/2/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > > If I try to specify the path using > > > > > > request.path = ''/something/somewhere'' > > > get ''my_action_name'' > > > > > > the path comes out as ''/''. > > > > This is all stuff related to Integration Testing, which I''m guessing > > is what you read about. > > > > > Can anyone instruct me on how to do this correctly? > > > > I think this should be answered by now. Write back if you still don''t > > understand. > > > > -- > David Leal > 969 572 510 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Leal
2007-Jul-02 15:43 UTC
[rspec-users] Testing route globbing and limitations of get()
Thanks for your answers, David. I''ll investigate. It''s still a bit hard for me to understand where are the boundaries between rails tests and rspec. Cheers, David On 7/2/07, David Chelimsky <dchelimsky at gmail.com> wrote:> > On 7/2/07, David Leal <dgleal at gmail.com> wrote: > > Hi David, thanks for your reply. > > > > Regarding the last topic below, there''s something about which I''m not > quite > > clear: > > > > The catchall method that I''m trying to test works by getting a path from > the > > request object passed to it (during testing it''s a TestRequest object). > If I > > understand correctly, there is no way to test this method without > writing an > > integration test. But shouldn''t the request object honor the path I''ve > set > > instead of resetting it? > > I''ve never tried to do what you''re doing so I can''t answer from > experience. What I can tell you is that the TestRequest object is part > of Rails, not rspec, so you might have some good luck on the rails > forums and mailing lists. >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070702/4d688559/attachment.html
David Chelimsky
2007-Jul-02 15:46 UTC
[rspec-users] Testing route globbing and limitations of get()
On 7/2/07, David Leal <dgleal at gmail.com> wrote:> Thanks for your answers, David. I''ll investigate. It''s still a bit hard for > me to understand where are the boundaries between rails tests and rspec.Spec::Rails, RSpec''s rails plugin, wraps test/unit, so: Model Examples work like Rails unit tests View, Controller and Helper Examples work like Rails functional tests We don''t have a parallel to Rails integration tests. That help?> > Cheers, > > David > > > On 7/2/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > On 7/2/07, David Leal <dgleal at gmail.com> wrote: > > > Hi David, thanks for your reply. > > > > > > Regarding the last topic below, there''s something about which I''m not > quite > > > clear: > > > > > > The catchall method that I''m trying to test works by getting a path from > the > > > request object passed to it (during testing it''s a TestRequest object). > If I > > > understand correctly, there is no way to test this method without > writing an > > > integration test. But shouldn''t the request object honor the path I''ve > set > > > instead of resetting it? > > > > I''ve never tried to do what you''re doing so I can''t answer from > > experience. What I can tell you is that the TestRequest object is part > > of Rails, not rspec, so you might have some good luck on the rails > > forums and mailing lists. > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Leal
2007-Jul-02 16:31 UTC
[rspec-users] Testing route globbing and limitations of get()
I see. It''s simple. Sorry that I missed that. I looked at Mephisto''s tests to see how they do it. Turns out you need to call get :action, :path => ["all", "path", "components"] # for /all/path/components Again, thanks for the help, David. Cheers, David On 7/2/07, David Chelimsky <dchelimsky at gmail.com> wrote:> > On 7/2/07, David Leal <dgleal at gmail.com> wrote: > > Thanks for your answers, David. I''ll investigate. It''s still a bit hard > for > > me to understand where are the boundaries between rails tests and rspec. > > Spec::Rails, RSpec''s rails plugin, wraps test/unit, so: > > Model Examples work like Rails unit tests > View, Controller and Helper Examples work like Rails functional tests > > We don''t have a parallel to Rails integration tests. > > That help? >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070702/f8f714b0/attachment.html