Testing views with RSpec


I’m making my first app using BDD. I’m using RSpec with Steak for
acceptance tests and Capybara.

It is a good idea to test all views, for example login or sign up
form, to check if all the inputs are rendered, if password input is of
type=“password” etc.? Or rather while doing BDD it is not practiced to
write also views specs?

And if yes, how can we test views, to check for example for existence
of some input? I see that Capybara have method such as has_selector?,
but unfortunately it didn’t work in views specs. I think that testing
views by only contains?() method could be uncomfortable, for example
to check for password field we would write:
rendered.should contain(’<input type=“password” name=“user[password]” /

'), but it won’t work, if that input have for example some css

So, what are the practices in BDD on testing views?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs