如何设置Rails系统测试的膨化 [英] How to setup puffing-billy to Rails System Test
问题描述
我正在尝试设置puff-billy以与Rails System Test一起使用.由于它为此使用Capybara,因此我在这里尝试了所有记录在案的Capybara解决方案,但似乎没有正确设置它.
I'm trying to setup puffing-billy to work with Rails System Test. Since it uses Capybara for that, I tried all the documented Capybara solutions here, but didn't seem to get it correctly setup.
系统测试为配置文件生成一个application_system_test_case.rb
.看起来是这样的:
System Test generates an application_system_test_case.rb
for config stuff. Here's how it looks like:
require "test_helper"
require 'billy'
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400]
Capybara.javascript_driver = :selenium_chrome_billy
Capybara.current_driver = Capybara.javascript_driver
WebMock.allow_net_connect!
end
实际的测试文件如下:
require "application_system_test_case"
class PromotionsTest < ApplicationSystemTestCase
include ApplicationHelper
make_my_diffs_pretty!
Capybara.default_max_wait_time = 3
Capybara.configure do |config|
config.app_host = "http://dev.myapp.com"
end
test 'Stub test' do
proxy.stub('http://www.google.com/').and_return(:text => "I'm not Google!")
visit 'http://www.google.com/'
end
end
但是当我运行测试时:
NameError: undefined local variable or method 'proxy' for #<PromotionsTest:0x00007fd357450c90>
.
But then when I run the tests:
NameError: undefined local variable or method 'proxy' for #<PromotionsTest:0x00007fd357450c90>
.
我在做什么错了?
推荐答案
IIRC puffing-billy不会安装系统测试的帮助程序,因此您需要通过Billy名称空间访问代理
IIRC puffing-billy doesn't install helpers for system tests so you'll need to access the proxy via the Billy namespace
Billy.proxy.stub(...)
此外,系统测试会覆盖javascript_driver',
current_driver , etc so you need to specify the driver you want to use via
driven_by`
Also, system tests override javascript_driver',
current_driver, etc so you need to specify the driver you want to use via
driven_by`
driven_by :selenium, using: :selenium_chrome_billy
注意:我不在我的主计算机上,所以这一切都不在我的脑海,也许不是100%正确,但应该使您走上正确的道路.
Note: I'm away from my main computer so this is all off the top of my head and may not be 100% correct but should put you on the right path.
这篇关于如何设置Rails系统测试的膨化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!