



Tried pretty much everything I could find on here with no luck. Oh, the sweet smell of passing tests in Terminal.You didn’t have to add a Docker image or anything? I tried adding that with no luck. Then I tested it by visiting Google: describe "GET Google homepage", :type => :feature do it 'welcomes the user to Google' do visit(' ') expect(page.title).to have_content("Google") puts " cool, Google's title is 'Google' " end endįinally, I started testing my app, by visiting it at the URLs where I could expect to find it, since I had my backend and frontend servers running: describe "GET '/' - homepage title", :type => :feature do it 'welcomes the user to Word Nerds' do visit(' expect(page.title).to have_content("Word Nerds") puts 'the homepage title is Word Nerds' end end describe "GET '/' - homepage", :type => :feature do it 'welcomes the user to Word Nerds' do visit(' expect(page).to have_content("Word Nerds") puts 'cool, the homepage has words on it' end end describe "GET '/login", :type => :feature do it 'shows a login form' do visit(' expect(page).to have_content("Login") puts 'cool, the login form page says Login' end end Success 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 gem capybara - gem poltergeist - gem headless + gem capybara. I’m using RSpec, so I added a folder to spec, spec/features webdriver-unable-to-find-mozilla-geckodriver gem selenium-webdriver. 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'
