Joe12 Joe12 - 1 month ago 23
Ruby Question

undefined method `visit' for #<Object (NoMethodError) capybara rspec

I am getting an error undefined method `visit' for



require "selenium-webdriver"
require "rubygems"
require "cucumber"
require "capybara"
require 'capybara/rspec/matchers'
Capybara.default_driver = :selenium

Answer

As documented you need to require 'capybara/cucumber' to include the capybara dsl methods into cucumber tests. If you have an issue with doing that you'd need to call all the methods on current_session like Capybara.current_session.visit('/').