Agile Web Development with Rails 6 Chapter 13. Task H
Currently reading and working through AWDR6 by Sam Ruby, David Bryant Copeland, and Dave Thomas. I have run into a couple issues and worked through them. I couldn’t find some solutions so decided to make a work log here for anyone else that might be working through this book.
The Pragmatic Programmers are amazing enough to have hosted this book on Medium as well. If you are interested in following along, or practicing yourself follow the link .
Worked with React in Rails which was a lot different than what I was expecting this book to go. But I am comfy with React so it wasn’t a hard chapter.
Summary
- We replaced a static form_select field with a dynamic list of form fields that change instantly based on user selection.
- We used Webpacker to gather up and deliver all of the necessary JavaScript dependencies just in time to the browser to make the dynamic changes happen.
- We used Capybara and ChromeDriver to system-test this functionality.
Playtime
This play time is brought to you by Capybara.
[✓] — ‘Check’ is not the only payment type, and routing number is not the only field that is dynamically inserted or deleted based on the payment type. Extend the system test to include other choices and other fields.
Issue: No issue, just more DSLs. Add this to minitest, rspec, jest, dom-test-library, they all kind of meld on methods. Still need to work on methodology for testing though.
Investigation: I linked the Capybara dsl above. Luckily it is a pretty short and easy one to scan.
Solution: Using the testing method we covered in the chapter I just extended it to other fields. This is one such field I extended.
[✓] — Add a test to verify that the ‘Add to Cart’ and ‘Empty Cart’ buttons reveal and hide the cart, respectively.
[✓] — Add a test to the highlight feature you added in Iteration F3: Highlighting Changes, on page 164.
Both of these I tackled on a new file called stores_test.rb as it is the root_url and the place where both tasks will be taking place. Feel free to look at my source code below.
After this book I am going to go through the upcase by thoughtbot course on TDD in Rails to help get a better grasp of methodology. Right now I feel like I am just piecing it together. Resource below