Search code examples
ruby-on-railsrspecintegration-testingwebrat

Rails/Rspec: How to specify a specific form when using "fill_in"


I have two forms on a page - one for login, one for signup, and both share a field called "user[username]"

When running integration tests in rSpec, how do I specify that I want actions to be run on a specific form?

In solid terms, if I have a form with id 'login' and a form with id 'signup', how do I specify that I want all "fill_in", "click_button" etc commands to be run on the "signup" form?


Solution

  • You just need add some scope define by css selector. So you just need to say you want fill user[name] form in form #login_form or #signup_form