Created
February 9, 2015 16:41
-
-
Save asbestossupply/1cb5949d1055a1fed3db to your computer and use it in GitHub Desktop.
Demo Capybara integration for Barge
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
require 'capybara/rails' | |
require 'barge' | |
class DemoTest < ActionDispatch::IntegrationTest | |
def setup | |
Capybara.default_driver = :selenium | |
Capybara.run_server = false | |
configure_for_barge if ENV['BARGE'] | |
end | |
test 'bargeapp.com is the lucky result for bargeapp.com query' do | |
visit('http://www.google.com') | |
fill_in 'q', with: 'bargeapp.com' | |
click_button "I'm Feeling Lucky" | |
assert page.current_url.start_with?('https://www.bargeapp.com') | |
end | |
private | |
def configure_for_barge | |
@barge_client = Barge::Client.new api_key: 'abcdef123456' | |
session = @barge_client.create_webdriver_session | |
while session['status'] == 'pending' | |
sleep 2 | |
session = @barge_client.describe_webdriver_sessions(session['id']) | |
end | |
Capybara::Selenium::Remote.use session['ip'], url: "http://#{session['ip']}:#{session['port']}/" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment