Why Write Rails View Tests

01-Apr-2021 1486
There are many ways to test a Ruby on Rails application, but there is one way that is not so often discussed. That is the way of testing Rails views. Yes - there are controller, model, and other types of tests, but we rarely see the view layer tests. Let’s give them more attention and see what they are all about.You might ask - well, why don’t you write integration tests and test view layer with them? I could, but running integration tests can be slow, and writing a simple view ‘unit’ test can be more straightforward. Plus, RSpec has great support for writing a view spec. What is even more interesting, I created an example project to test these out. Let’s see what I found out.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle