On 28 Mar 2011, at 22:52, Peter Laurens <li...@ruby-forum.com> wrote:

>    match 'sessions' => 'sessions#create', :via => :put
>    match 'sessions' => 'sessions#destroy', :via => :delete
> 
> Essentially I want a user to send a put (this is an idempotent
> operation) to the sessions collection URL, with a params hash of
> username and password. And calling delete on the same URL will log out
> the session.
> 
> However, my RSpec test, which looks like this:
> 
> describe "PUT 'new'" do
>    # (NB this user is created in the 'before' method)
>    it "should be successful" do
>      put 'new', {:name => 'a_user_logging_in', :password =>
> 'a_password'}
>      response.should be_success
>    end
> 
>    it "should not be successful with a wrong username or password" do
>      put 'new', {:name => 'an_incorrect_user', :password =>
> 'a_password'}
>      response.should_not be_success
>    end
> end
> 
> 
> Does not pass as the routing fails! Here is the RSpec error:
> 
> Failure/Error: put 'new', {:name => 'a_user_logging_in', :password =>
> 'a_password'}
>     ActionController::RoutingError:
>       No route matches {:name=>"a_user_logging_in",
> :password=>"a_password", :controller=>"sessions", :action=>"new"}
> 
> So clearly I've made an error here somewhere with my Routes, can someone
> help me achieve what I'm after (i.e. just a put and delete on a
> collection, which calls create and destroy on the controller?).
> 

You've routed put to the create action but in your spec you're calling the new 
action - the 2 need to match up. 

Fred

> Many many thanks for your kind help,
> 
> - Nex
> 
> -- 
> Posted via http://www.ruby-forum.com/.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
> 

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

Reply via email to