【发布时间】:2019-07-02 14:12:30
【问题描述】:
我正在尝试设置 puffing-billy 以使用 Rails 系统测试。因为它使用 Capybara,所以我在这里尝试了所有记录在案的 Capybara 解决方案,但似乎没有正确设置。
系统测试为配置内容生成application_system_test_case.rb。下面是它的样子:
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>.
我在这里做错了什么?
【问题讨论】:
标签: ruby-on-rails mocking system-testing