On 17 Jan 2009, at 23:34, James Byrne wrote:

James Byrne wrote:


I have spent a good deal of time trying to get this to work with no
success.  I have read the api regarding the put method in:

ActionController::Integration::Session

If I read this aright then in your example user should be a hash, but a
hash of what? Where would I create it in my test and what should it
contain?

I ended up with this:

:user => User.find(:first)

When /user named "(.*)" enables the administrator role/ do |name|

put users_url( :user => User.find_by_username!(name) ), :user =>
{:administrator => true}

end

Which at least does not blow up on me.  But it does not set the
administrator flag to true either.

If you look at the Rails documentation for the named route methods, I think you might want to try something a bit more like this:

    user = User.find_by_username!(name)
    put users_url(user, :user => {:administrator => true})

If you think you know the URL you want, why not try hard-coding it for a while in the step until you get the desired effect on the controller? Then you can add a spec for your routing which proves that the call to users_url() with the parameters you're trying gives you the same hard-coded value. Then you'll have discovered for yourself exactly the right parameters to use to send the right PUT request all the way to the controller.

Make sense?

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com

_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to