How to setup puffing-billy to Rails System Test

ε祈祈猫儿з 提交于 2019-12-25 01:13:28

问题


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.

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

And the actual test file looks like this:

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

But then when I run the tests: NameError: undefined local variable or method 'proxy' for #<PromotionsTest:0x00007fd357450c90>.

What am I doing wrong here?


回答1:


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(...)

Also, system tests override javascript_driver',current_driver, etc so you need to specify the driver you want to use viadriven_by`

driven_by :selenium, using: :selenium_chrome_billy

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.



来源:https://stackoverflow.com/questions/56854435/how-to-setup-puffing-billy-to-rails-system-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!