Search code examples
rspecrspec-rails

Views have their own rspec file


I just started using rspec for testing and was wondering whether it was important for each view to have its own test file. I think I would be better off staring with the best practices than realize down the road.


Solution

  • Unless you're not expecting any changes to the views I would recommend not testing it. The only test I would consider is checking if the view has something important displayed like the title, and also the http request response is 200.

    From my experience the views change constantly, and it'll break dozens every time you make a small change, it's not worth the effort, this is a good article discussing the important of testing certain parts of your code (bottom page)