我正在尝试开始在应用程序上编写测试,但是js: true
出现问题,这无法启动自己的服务器。
环境金属
rails -v #Rails 5.2.0
ruby -v ruby 2.4.2p198
宝石文件:
gem 'capybara'
gem 'selenium-webdriver'
我遵循了本教程中的配置 https://www.devmynd.com/blog/setting-up-rspec-and-capybara-in-rails-5-for-testing/
我知道它没有启动自己的服务器,因为这是我得到的错误
Failures:
1) Login
Failure/Error: expect(page).to have_content("Sarah")
expected to find text "Sarah" in "This site can’t be reached\nlocalhost refused to connect.\nTry:\nChecking the connection\nChecking the proxy and the firewall\nERR_CONNECTION_REFUSED\nReload\nDETAILS"
# ./spec/helpers/login.rb:9:in `login_user'
这是#./spec/helpers/login.rb:9:“login_user”文件中的内容
require "rails_helper"
RSpec.feature "Financial Profile", :type => :feature do
scenario "just login", js: true do
login_user
end
def login_user
user = FactoryBot.create(:user, email: 'sconnor@myfefa.com', name: 'Sarah Connor')
login_as(user, :scope => :user, :run_callbacks => false)
visit root_path
expect(page).to have_content("Sarah")
expect(page).to have_link("Logout")
end
end
现在,如果我做到了,这将非常完美
scenario "just login", js: false do
login_user
end