Skip to content

Instantly share code, notes, and snippets.

@sauy7

sauy7/Gemfile Secret

Last active May 18, 2018 06:07
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sauy7/1b081266dd453a1b737b to your computer and use it in GitHub Desktop.
Save sauy7/1b081266dd453a1b737b to your computer and use it in GitHub Desktop.
Example showing use of puffing-billy gem with webmock, selenium, minitest and minitest-metadata in a Rails project
# test/support/billy.rb
require 'billy'
Billy.configure do |c|
# configuration options
end
Billy.register_drivers
module Billy
module MinitestHelper
def proxy
Billy.proxy
end
end
end
# test/integration/exmaple_test.rb
require 'test_helper'
class ExampleTest < ActionDispatch::IntegrationTest
it "tests with puffing billy", billy_selenium: true do
...
end
end
group :test
gem 'puffing-billy'
gem 'minitest-metadata', require: false
gem 'capybara_minitest_spec'
gem 'selenium-webdriver'
gem 'webmock'
end
# test/test_helper.rb
require 'support/billy'
class ActionDispatch::IntegrationTest
include Capybara::DSL
include MiniTest::Metadata
include Billy::MinitestHelper
before do
if metadata[:billy_selenium] == true
WebMock.allow_net_connect!
Capybara.javascript_driver = :selenium_billy
Capybara.current_driver = Capybara.javascript_driver
end
end
after do
if metadata[:billy_selenium] == true
WebMock.disable_net_connect!(allow_localhost: true)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment