[rspec-users] Testing route globbing and limitations of get()

David Chelimsky dchelimsky at gmail.com
Mon Jul 2 08:51:58 EDT 2007

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


> Cheers,
> --
> David Leal
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list