“不建议在全局范围内包含 Capybara::DSL!”想删除它。控制台警告
“including Capybara::DSL in the global scope is not recommended!” want to remove it. console warning
解决错误访问未找到。我在我的辅助模块之一中包含了 include 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: 'shinsaurab@gmail.com', :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
如果我做错了什么,有人可以提出建议吗?我尝试了一些建议,但对我没有用
我遇到了类似的问题,尝试了很多方法,但对我有用的是从 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: 'shinsaurab@gmail.com', :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
谢谢!
如果您有任何疑问,请告诉我
解决错误访问未找到。我在我的辅助模块之一中包含了 include 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: 'shinsaurab@gmail.com', :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
如果我做错了什么,有人可以提出建议吗?我尝试了一些建议,但对我没有用
我遇到了类似的问题,尝试了很多方法,但对我有用的是从 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: 'shinsaurab@gmail.com', :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
谢谢! 如果您有任何疑问,请告诉我