Isnor Creative
Isnor Creative Blog
Ruby, Ruby on Rails, Ember, Elm, Phoenix, Elixir, React, Vue

Nov 16, 2018

Testing vue-select with Capybara

I recently wrote some feature tests with Rspec and Capybara for a Rails application that made use of the vue-select component. This needs to be done with a js driver such as headless-chrome activated. This method worked for me:

  scenario 'prefill from book', js: true do
    visit x_path
    page.find('ul.dropdown-menu li a', text: item.title).click
    click_button "Submit"
    expect(page).to have_text('something expected')

I have been using Vue a fair bit in a number of Ruby on Rails projects that I maintain. I’ve been finding it great for features where a full-blown single page application is not necessary, but there is interactive behavior on the page that might otherwise become a mess of hard to maintain javascript. Vue is easy to install in Rails thanks to webpacker, and a breeze to use.

I am available for Ruby on Rails and Vue consulting work – get in touch to learn more!

Gordon B. Isnor

Gordon B. Isnor writes about Ruby on Rails, Ember.js, Elm, Elixir, Phoenix, React, and the web.
If you enjoyed this article, you want to join his newsletter.

comments powered by Disqus