#Testing

Archive of blog posts tagged with "testing"

  • Add taggable support to my personal blog

    In today's post, I discuss enhancing my blog's tag support, moving from a simple comma-separated list to a more powerful and dynamic queryable system using the Ruby gem 'acts-as-taggable-on'. I illustrate the process of installing and migrating the gem with MySQL. I then detail the code for tagging in the Blog model, updating blog forms and controllers. It's crucial to migrate existing tags to the new system, which I did using Maintenance Tasks, including tips for covering edge cases in the tests for the task. Updating existing tests for the blog model to incorporate the new taggable system was the final step. Future considerations include creating a Stimulus Controller for auto-suggested tags and extending this functionality to the Project model.

  • Getting Familiar with RSpec in Rails

    I spent some time over the weekend getting familiar with RSpec. Gonna brain dump (with just a little bit of structure) the process and what I did and learned. To start I set up in a new rails project and kinda tweaked it into a place where I can be productive.

  • Enforcing Interfaces in Ruby

    Ruby doesn't have the concept of an interface. Unlike say, PHP. In PHP you can specify that a class has to act like or implement specific methods. If your class fails to honor the contract of that interface and does not implement the methods of the interface, you get an error during runtime. Ruby does not have this. But we can ensure our code honors the contract of an interface by writing unit tests for our classes.

‹ Prev
1
Next ›