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
#!/usr/bin/env ruby | |
# rubygems manages gem loading | |
require "rubygems" | |
require "selenium-webdriver" | |
# test::unit is now part of the standard suite | |
require "test/unit" | |
class RubyExample < Test::Unit::TestCase |
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
tracked_attr_accessor :something | |
def self.tracked_attr_accessor(*methods) | |
methods.each do |method| | |
attr_reader method | |
self.define_method("#{method}=") do |arg| | |
if method != arg | |
updated_fields << method | |
instance_variable_set("@#{method}", arg) | |
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
http = "https://saucelabs.com/rest/v1/#{username}/jobs/#{job_id}" | |
body = {"name" => "Log In Test"}.to_json | |
RestClient::Request.execute( | |
:method => :put, | |
:url => http, | |
:user => username, | |
:password => access_key, | |
:headers => {:content_type => "application/json"}, |
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
group :test do | |
gem 'cucumber-rails', :require => false | |
gem 'sauce-cucumber', :require => false | |
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 "spec_helper" | |
describe "Some functionality", :js => true do | |
it "does a thing" do | |
visit "a page" | |
page.driver.browser.switch_to :alert | |
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
## features/step_definitions/a_step_definition.rb | |
Given /$Anything$/ | |
$driver.navigate.to "http://www.something.awesome.com" | |
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
Given /^I upload (\w+)$/ do |filepath| | |
# page.driver.browser gives you the Selenium object | |
selenium = page.driver.browser | |
selenium.file_detector = lambda do |args| | |
# Capybara checks the file exists so we can just return the first argument, the file path | |
args.first.to_s | |
end | |
# Scope to a specific form |
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 "cucumber/formatter/pretty" | |
module Sauce | |
class SauceFormatter < Cucumber::Formatter::Pretty | |
def initialize(step_mother, io, options) | |
super | |
end | |
def before_step(step) | |
message = "Cucumber step -- #{step.name}" |
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
def quit | |
STDERR.puts "Capybara::Selenium::Driver.quit called by #{caller}" | |
@browser.quit if @browser | |
rescue Errno::ECONNREFUSED |
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' | |
require 'selenium/webdriver/remote/http/persistent' | |
http_client = ::Selenium::WebDriver::Remote::Http::Persistent.new | |
url = "http://#{ENV["SAUCE_USERNAME"]}:#{ENV["SAUCE_ACCESS_KEY"]}@ondemand.saucelabs.com:80/wd/hub" | |
capabilities = Selenium::WebDriver::Remote::Capabilities.safari | |
capabilities.platform = 'OS X 10.6' | |
capabilities.version = '5' | |
Capybara.register_driver :remote_browser do |app| | |
Capybara::Selenium::Driver.new(app, | |
:browser => :remote, :url => url, |