“不建议在全球范围内使用Capybara :: DSL!”想要删除它。控制台警告

问题描述 投票:0回答:1

要解决该错误,找不到访问。我已经在我的一个辅助模块中包括了Capybara :: DSL,如下所示:我正在使用ruby 2.7.0

include Capybara::DSL

module LoginHelper
  def self.login_user
    visit 'https://staging.have2have.it/login'  
    within(".container-fluid") do
      fill_in("email", with: '[email protected]', :match => :prefer_exact)
      fill_in("password", with: '123', :match => :prefer_exact)
    end
    click_button('Log In')
  end
end

spec_helper.rb

require 'capybara'
require 'capybara/dsl'
require 'capybara/rspec'
require './spec/helpers/login_helper'

Capybara.default_driver = :selenium

RSpec.configure do |config|
  config.include Capybara::DSL
  config.include LoginHelper
end

任何人都可以建议我是否做错了什么。我尝试了一些建议,但对我没有用]

ruby capybara integration-testing
1个回答
0
投票

我曾遇到过类似的问题,尝试了很多事情,但对我有用的是从spec_helper中删除config.include Capybara :: DSL并将LoginHelper包含在Helpers模块中。就您而言,它们可能如下所示:

login_helper.rb

module Helpers
  module LoginHelper
    def login_user
      visit 'https://staging.have2have.it/login'  
      within(".container-fluid") do
        fill_in("email", with: '[email protected]', :match => :prefer_exact)
        fill_in("password", with: '123', :match => :prefer_exact)
      end
      click_button('Log In')
    end
  end
end

spec_helper的外观如下:

require 'capybara'
require 'capybara/dsl'
require 'capybara/rspec'
require './spec/helpers/login_helper.rb'

Capybara.default_driver = :selenium

RSpec.configure do |config|
  config.include Helpers::LoginHelper
end

谢谢!如果您有任何疑问,请告诉我

© www.soinside.com 2019 - 2024. All rights reserved.