Visit method not found in my rspec

左心房为你撑大大i 提交于 2019-11-27 03:48:44

Regarding to rspec issues (https://github.com/rspec/rspec-rails/issues/360)

you should put

config.include Capybara::DSL

in spec_helper.rb, inside the config block.

The default directory that Capybara::RSpec now looks at to include the Capybara::DSL and Capybara::RSpecMatchers is changed from requests to features.

After I renamed my requests directory to features I got the matcher and DSL methods available again without having to explicitly include them.

See the following commit

shadowbrush

Also make sure your tests are in the /spec/features directory. According to rspec-rails and capybara 2.0, Capybara v2 and higher will not be available by default in RSpec request specs. They suggest to "...move any tests that use capybara from spec/requests to spec/features."

By default the capybara DSL is included automatically if the file is in spec/requests, spec/integration or if the example group has :type => :request.

Because your file is in spec/home the capybara helpers aren't being included. You can either conform to one of the patterns above or adding include Capybara::DSL should also do the trick (you might also need to replicate some of the before(:each) stuff that would be setup.)

First check it out

If you are not success,

Add this code your end of the your spec helper actually out of the RSpec.configure block as well

module ::RSpec::Core
  class ExampleGroup
    include Capybara::DSL
    include Capybara::RSpecMatchers
  end
end
Anatoliivna

1) Add to ‘rails_helper’ config:

config.include Capybara::DSL
config.include Capybara::RSpecMatchers

And comment out the `require 'spec_helper'` line.

2) Add to 'spec_helper':

require 'rails_helper'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!