[rspec-users] RSpec in Rails -- HTTP methods

Pat Maddox pergesu at gmail.com
Wed Sep 10 14:49:29 EDT 2008


On Wed, Sep 10, 2008 at 1:24 PM, Mark Dodwell <lists at ruby-forum.com> wrote:
> It seems that RSpec-Rails isn't restricted to the HTTP methods
> correctly.
>
> For example doing:
>
>   http://foo.local/session/destroy
>
> in the browser doesn't work, because the destroy action is only
> recognised with the HTTP 'delete' verb.
>
> But in Rspec specs if you do:
>
>  get :destroy
>
> It works.
>
> Is this intended behaviour or a bug?

Rails uses routing to map DELETE /session to
SessionController#destroy.  Controller specs don't use routing.
Whenever you do get/put/post/delete in your spec, you're effectively
doing

SessionController.new.destroy

except you can't simply do that, because ActionPack is a rat's nest of
dependencies.

Pat


More information about the rspec-users mailing list