Created
July 27, 2015 21:36
-
-
Save DylanLacey/85c66207b5a7085c920a to your computer and use it in GitHub Desktop.
MYO Sauce Ruby integration
This file contains hidden or 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
source "https://www.rubygems.org" | |
# All your other gems | |
gem "selenium-webdriver" | |
gem "sauce_whisk" |
This file contains hidden or 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_relative "spec_helper" | |
describe "Google's Search Functionality" do | |
it "can find search results", :run_on_sauce => true do | |
@driver.manage.timeouts.implicit_wait = 10 | |
@driver.navigate.to "http://www.google.com" | |
raise SystemError("Unable to load Google.") unless @driver.title.include? "Google" | |
query = @driver.find_element :name, "q" | |
query.send_keys "Sauce Labs" | |
query.submit | |
puts @driver.title | |
end | |
end |
This file contains hidden or 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 "selenium/webdriver" | |
module SauceDriver | |
class << self | |
def sauce_endpoint | |
"http://#{ENV["SAUCE_USERNAME"]}:#{ENV['SAUCE_ACCESS_KEY']}@ondemand.saucelabs.com:80/wd/hub" | |
end | |
def caps | |
caps = { | |
:platform => "Mac OS X 10.9", | |
:browserName => "Chrome", | |
:version => "31" | |
} | |
end | |
def new_driver name | |
test_caps = caps.merge({:name => name}) | |
Selenium::WebDriver.for :remote, :url => sauce_endpoint, :desired_capabilities => test_caps | |
end | |
end | |
end |
This file contains hidden or 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 "rspec" | |
require "sauce_whisk" | |
require_relative "sauce_helper" | |
RSpec.configure do |config| | |
config.around(:example, :run_on_sauce => true) do |example| | |
job_name = example.metadata[:full_description] | |
@driver = SauceDriver.new_driver job_name | |
session_id = @driver.session_id | |
begin | |
example.run | |
success = example.exception.nil? | |
ensure | |
@driver.quit | |
SauceWhisk::Jobs.change_status session_id, success | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment