

I tested this by first visiting my API: describe "GET '/users' - from API", :type => :feature do it 'checks the first user in the database' do visit(' expect(page).to have_content("bob") puts 'cool, bob is in the house!' end end Finally I realized I need to visit the actual URL.

That route would probably work if my whole app were a Rails app, but my frontend was build with React. I had some trouble with the Capybara visit method, because I thought I’d be able to visit('/') to visit my homepage, but that kept giving me errors. Within my spec directory, I created a features folder, and within that I created a file, home_spec.rb, so named to test my app’s homepage. Within that folder, I created a file, home_spec.rb, that looks like this: require 'spec_helper' class Home include Capybara::DSL def visit_homepage visit('/') end end feature "Visit homepage" do let(:home) ) end Capybara.javascript_driver = :poltergeist fault_driver = :poltergeist I’m using RSpec, so I added a folder to spec, spec/features Then add this line to your test helper file, AKA spec_helper.rb: require 'capybara/rails' 2. Setupįirst, add this line to your Gemfile and run bundle install: gem 'capybara'
