0

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?

PuckXY
  • 59
  • 3

1 Answers1

0

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.

Thomas Walpole
  • 48,548
  • 5
  • 64
  • 78