Topic: RSpec Request Specs

Hi - I have a site home page that has a new user form and a sign-in form on the same page (kind of like facebook).

When I try to do a request spec for the new user form, the username and password are being applied to the login form section of the page...so, when the spec presses the signup button, the username and password sections are blank.

So, when using RSpec, how to I tell it to fill_in a specific box when there's another box with the same id?

Thanks!!!

Re: RSpec Request Specs

CSS ids are supposed to be unique. So if you have these forms on the same page then you need to make the ids different.

Re: RSpec Request Specs

Thanks for the reply...but I figured out another solution...

The webrat docs pointed me in the direction of calling the form field attribute name.  so, for example, instead of:

fills_in "Password"

which would fill in the password box that belongs to the sign in function (and the sessions controller) rather than the sign up function, I could use

fills in "user[password]"

and this fills in the specific form input associated with the user controller.

Re: RSpec Request Specs

Sweet. CSS ids on a page are meant to be unique. You should fix that anyway, if you don't it'll bite you on the arse again.

Last edited by cherring (2011-07-29 02:29:27)