Originally post on the EightyTwenty Blog
Basecamp’s Trix Editor is really an amazing tool. With it you can create fully functional and easy to use editors for your users that look great.
At Dringo we have a Ruby on Rails stack and love to back our code up with tests. I found that using Capybara with the Trix Editor is a bit confusing at first, so here is some useful code to help.
First, here are the fixtures we’re working with:
And here we make sure to autoload support files in MiniTest:
We’re going to write two helpers to aid us in creating our tests. The first is a setter that interacts with the actual Trix Editor. The second is a getter, that finds the hidden input field Trix uses to store its value.
Finally, these tests demonstrate how we can use helper methods:
Hope this helps. Enjoy!