-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test/integration/exmaple_test.rb | |
require 'test_helper' | |
class ExampleTest < ActionDispatch::IntegrationTest | |
it "tests with puffing billy", billy_selenium: true do | |
... | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group :test | |
gem 'puffing-billy' | |
gem 'minitest-metadata', require: false | |
gem 'capybara_minitest_spec' | |
gem 'selenium-webdriver' | |
gem 'webmock' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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