Giter Club home page Giter Club logo

sauce_ruby's Introduction

#[DEPRECATED] Sauce Labs does not recommend this gem. It will not receive further development or support.

Sauce for Ruby

Build Status Dependency Status

This is the Ruby client adapter for testing with Sauce Labs, the multi-platform, multi-device testing service. The gem supports opening Sauce Connect tunnels, starting Rails applications, and most importantly, running your tests in parallel across multiple platforms.

Be sure to check the wiki for more information, guides and support.

Installation

# Gemfile
gem "sauce"
gem "sauce-connect" # Sauce Connect is required by default.
$ bundle install

Configure your access credentials as environment variables:

SAUCE_USERNAME= Your Username
SAUCE_ACCESS_KEY = Your Access Key, found on the lower left of your Account page (NOT your password)

If environment variables aren't your thing, check out the (in)Complete guide to Configuration for other options.

Appium Tests

The Sauce gem does not currently support WebDriver 3.0 style capabilities correctly. This means that the gem can not be used to run tests against sessions using Appium 1.0 and above, including mobile browser tests.

RSpec

$ bundle exec rake sauce:install:spec

Tag each example group you wish to use Sauce to run with :sauce => true:

describe "A Saucy Example Group", :sauce => true do
  it "will run on sauce" do
    # SNIP
  end
end

Place your Sauce.config block in spec_helper.rb

Test::Unit

Create test/sauce_helper.rb with your desired config, and require sauce_helper in your test_helper.rb

Cucumber

## Gemfile
gem "sauce-cucumber", :require => false
gem "sauce"
$ bundle install
$ bundle exec rake sauce:install:features

Edit features/support/sauce_helper.rb with your desired config.

Tag your Sauce-intended features with @selenium.

Using the gem

RSpec

Every test with Sauce behaviour included gets access to its own selenium driver, already connected to a Sauce job and ready to go.

This driver is a Sauce subclassing of the Selenium driver object, and responds to all the same functions.

It's available as page, selenium and s, eg

describe "The friend list", :sauce => true do
  it "should include at least one friend" do
    page.navigate_to "/friends"
    page.should have_content "You have friends!"
  end
end

We recommend, however, the use of Capybara for your tests.

Server Startup

If it guesses you're in a Rails project, the gem will spin up your Rails server (because it's needed for tests); If you're using a separate server, or your specs already start one, you can prevent this in your Sauce Config:

Sauce.config do |config|
  config[:start_local_application] = false
end

Run tests locally or remotely

A suggestion of how to run tests locally or remotely is available at the Swappable Sauce wiki page.

Capybara

The gem provides a Capybara driver that functions mostly the same as the existing Selenium driver.

## In your test or spec helper
require "capybara"
require "sauce/capybara"

# To run all tests with Sauce
Capybara.default_driver = :sauce

# To run only JS tests against Sauce
Capybara.javascript_driver = :sauce

You can now use Capybara as normal, and all actions will be executed against your Sauce session.

Inside an RSpec Example (tagged with :sauce => true)

If you're running from inside an RSpec example tagged with :sauce => true, the @selenium object and the actual driver object used by the Sauce driver are the same object. So, if you need access to the Selenium Webdriver when using Capybara, you have it.

You'll get automagic job creation and destruction, job naming and all our nice platform support using Capybara like this.

Outside an RSpec Example (tagged with :js => true)

If you're not using the RSpec hooks, Capybara will use a single Sauce Labs job until your tests exit. You can force Capybara to close your session (and then start another):

Capybara.current_session.driver.finish!
Capybara.reset_sessions!

When used like this, you won't get any of the shiny serial platform support that the :sauce tag provides; You'll have to use our REST API to name your jobs (Possibly using Sauce_Whisk and your specs will only operate on the first platform you've specified.

With Sauce Connect

Sauce Connect automatically proxies content on certain ports; Capybara.server_port will be set to a value suitable for use with Sauce Connect by default. If you want to use a specific port, using one of these will allow Sauce Connect to tunnel traffic to your local machine:

Capybara.server_port = an_appropriate_port

# Appropriate ports: 80, 443, 888, 2000, 2001, 2020, 2222, 3000, 3001, 3030, 3333, 4000, 4001, 4040, 4502, 4503, 5000, 5001, 5050, 5555, 6000, 6001, 6060, 6666, 7000, 7070, 7777, 8000, 8001, 8003, 8031, 8080, 8081, 8888, 9000, 9001, 9080, 9090, 9999, 49221

Cucumber

The sauce-cucumber gem works best with Capybara. Each "@selenium" tagged feature automatically sets the Capybara driver to :sauce. All tagged features can simply use the Capybara DSL directly from step definitions:

## a_feature.rb
@selenium
Feature: Social Life
  Scenario: I have one
    Given Julia is my friend
    ## SNIP ##

## step_definition.rb
Given /^(\w+) is my friend$/ do |friends_name|
 visit "/friends/#{friends_name}"
end

For more details, check out the wiki page, Cucumber and Capybara.

Test::Unit

To get sweeeeet Saucy features like job status updating, subclass Sauce::TestCase or Sauce::RailsTestCase.

Sauce::TestCase is a subclass of Test::Unit::TestCase, for simple test cases without anything extra.

Sauce::RailsTestCase is a subclass of ActiveSupport::TestCase so you can use all the associated ActiveSupport goodness.

Each test will have access to a fresh Sauce VM, already running and ready for commands. The driver is a subclass of the Selenium::WebDriver class, and responds to all the same functions. It can be accessed with the page, s and selenium methods.

## test/integration/some_test.rb
require "test_helper"

class FriendList < Sauce::TestCase

  def test_the_list_can_be_opened
    page.navigate.to "/friends"
    page.should have_content "You have friends!"
  end
end

We still recommend the use of Capybara, see above.

Uploading Files

Uploading files in Selenium is done by calling send_keys on a File input element, with the filename as the first parameter. Remote uploads usually require you to create a File Detector and pass it to the Driver after initialization.

The gem takes care of this for you, so uploading files from your local machine during tests should "JustWork(tm)".

Running your tests

Setting Capabilities & Platforms

Setting Platforms

The browsers array from Sauce.config takes individual arrays, each representing a single platform to test against. Each array is in the form [platform_name_and_version, browser_name, browser_version].

## Somewhere loaded by your test harness -- spec/sauce_helper or features/support/sauce_helper.rb
Sauce.config do |config|
  config[:browsers] = [
    ["Windows 7","Firefox","18"],
    ["Windows 7","Opera","11"]
  ]
end

Converting Sauce Labs capabilities

The values for the browsers array are terse versions of the capabilities generated by the Sauce Labs Platform Configurator; Use the 'platform' and 'version' capabilities directly, and use the name of the object you request from Selenium::WebDriver::Remote::Capabilities as the browser name. For example:

### Platforms Configurator
caps = Selenium::WebDriver::Remote::Capabilities.chrome
caps['platform'] = 'OS X 10.10'
caps['version'] = '39.0'

### Is equivalent to
["OS X 10.10", "chrome", "39.0"]

Adding additional capabilities

For every platform

All the standard Selenium & Sauce capabilities are accessible from the Sauce.config block. Some filtering is done to exclude nonsense caps. If you need to add a capability that's not already allowed (those in Sauce::Config::SAUCE_OPTIONS), you can add it to the whitelist:

Sauce.config do |config|
  # Build is already allowed
  config[:build] = "9001AMeme"

  # Shiny is not allowed yet
  config.whitelist 'shiny'
  config['shiny'] = "Something"
end
For a single platform

To set a capability for a single platform, add it as a hash to the end of the platform's array:

Sauce.config do |config|
  config.browsers = [
    ["Windows 7", "Firefox", "18"],
    ["Windows 7", "Chrome", 30, {:build => 'ChromeTastic'}]
  ]

Run tests in Parallel (Highly recommended)

$ bundle exec rake sauce:spec
$ bundle exec rake sauce:features

This will run your RSpec tests or Cucumber features against every platform defined, across as many concurrent Sauce sessions as your account has access too.

You can pass arguments to these tasks to control concurrency, specs/features to run and commandline arguments.

# Run login\spec across all platforms with up to 8 concurrent specs
$ bundle exec rake sauce:spec concurrency=8 test_files="spec/login_spec.rb"


# Run report.feature across all platforms with up to 3 concurrent features
$ bundle exec rake sauce:features concurrency=3 features="features/report.feature"

Check out the Parallisation guide for more details.

Run against several browsers in series

As long as your tests are correctly tagged (See installation, above), running them without the rake task (eg $ bundle exec rspec) will run them one at a time, once for every platform requested.

Network Mocking

If you're mocking out external network requests, say with WebMock or FakeWeb, you'll need to ensure that requests can still be made to saucelabs.com, as well as any subdomains.

You'll need to ensure you can make requests to your server as well.

WebMock

We've provided a helper for WebMock, which you can include with require 'sauce/webmock'. This will preserve all the existing config passed to WebMock.disable_net_connect!, while setting an exception for Sauce's servers. You'll need to include this helper after any other WebMock configuration

If you want full control of your mocking, just include saucelabs.com when allowing domains:

WebMock.disable_net_connect!(:allow => [/saucelabs.com/], "www.example.com")

When using the parallel testing rake tasks, the Sauce gem will reach out to the Sauce Labs REST API. If WebMock is active during Rake tasks, you can set the DISABLE_WEBMOCK_FOR_RAKE environment variable to 'true' to allow this to continue.

Reporting Results

RSpec 2, Test::Unit and Cucumber

If integrated with RSpec (as detailed above), the gem will automatically update your jobs' success (or failure) and name using the brand spankin' new SauceWhisk gem.

Running tests against firewalled servers

If your system under test is located behind a firewall, you can use Sauce Connect to run tests through your firewall, quickly and simply.

Sauce Connect is started by default, spinning up a tunnel prior to your tests and closing it down afterwards.

To disable Sauce Connect, set start-tunnel to false in your Sauce.config block:

Sauce.config do |config|
  config[:start_tunnel] = false
end

For details on named tunnels (including why you might want to use them) check out the Using Identified Tunnels with Sauce Connect page.

Full configuration details

Check out the for a full list of configuration options and details.

This also details how to customise application/tunnel setup.

Suggested Toolchain

The Sauce gem has been optimized to work most effectively with RSpec.

Troubleshooting

Check the Troubleshooting Guide

My tests keep erroring out with

You're either quitting your tests inside your test blocks, or something is going wrong with your test sessions. When the gem goes to quit the sessions, they then fail. This is revealed by design as having sessions closed during tests is considered to be bad thing.

If you're sure you want to supress this behaviour, you can do so by setting the suppress_session_quit_failures config value to true.

Contributing to the Gem

  • Fork the GitHub project
  • Create a branch to perform your work in, this will help make your pull request more clear.
  • Write some RSpec tests to demonstrate your desired capability or exhibit the bug you're fixing.
  • Run the tests - rake spec:unit runs the unit tests, rake spec: followed by connect,rspec or testunit runs that integration test, rake test runs everything
  • Make your feature addition or bug fix.
  • Commit
  • Send a pull request! :)

There is a Mailing List for developers.

Logging

The gem contains a logging facility. If left alone, it defaults to creating a Ruby::Logger that logs at WARN level to Standard Out. You can inject your own logger:

Sauce.logger= your_logger

Or, if you set the SAUCE_LOGFILE and SAUCE_LOGLEVEL environment variables, the gem will create a file logger which logs at that level. Logfiles will be created, appended too and rotated after 10Mb.

In parallel, each logfile will have the number of the parallel process appended to the filename; The rake task will log to the first file. Because of a quirk with how Parallel Tests numbers processes, the 'first' file will have no number, and the second will be numbered 2.

Testing the Gem

Running the full test suite will require RVM

  • Set SAUCE_USERNAME and SAUCE_ACCESS_KEY in your environment to valid Sauce credentials or create an ondemand.yml in the following format:

      access_key: <yourkeyhere>
      username: <yourusernamehere>
    
  • Invoke bundle install to install the gems necessary to work with the Sauce gem

  • Running rake spec:unit will run the RSpec unit tests

  • If you'd like to run the entire test suit, rake test will run all the integration tests, but requires the Sauce credentials to be set up properly as these tests will run actual jobs on Sauce.

Rakefile

If you see Exception occured: uninitialized constant Sauce::RSpec::Spec when requiring the sauce gem in the Rakefile, make sure to require bundler/setup.

require 'bundler/setup'
require 'sauce'

References

  • Cucumber -- Cucumber, the only BDD Framework that doesn't suck.
  • Capybara -- Don't handcode webdriver commands.
  • SauceWhisk -- Ruby REST API Wrapper for the Sauce API. Fresh New Minty Flavour!

Bitdeli Badge

sauce_ruby's People

Contributors

biril avatar bootstraponline avatar cory-klein avatar dylanlacey avatar elgalu avatar enrapt-mochizuki avatar epall avatar felixclack avatar forest avatar hawknewton avatar imurchie avatar jaysirju avatar jlipps avatar jodell avatar joeyrobert avatar jordan-brough avatar jsboulanger avatar jsmoxon avatar mrloop avatar quantumgeordie avatar ricardonacif avatar rickmzp avatar sah avatar santiycr avatar sponte avatar thewoolleyman avatar trobrock avatar uatcendyn avatar wanelo-pair avatar ywen2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sauce_ruby's Issues

Cucumber Around hook doesn't work with Scenario Outlines

      undefined method `feature' for #<Cucumber::Ast::OutlineTable::ExampleRow:0xb08eca0> (NoMethodError)
      /home/tyler/.rvm/gems/ree-1.8.7-2011.12@flexd/gems/sauce-1.1.24/lib/sauce/capybara/cucumber.rb:37:in `_scenario_and_feature_name'
      /home/tyler/.rvm/gems/ree-1.8.7-2011.12@flexd/gems/sauce-1.1.24/lib/sauce/capybara/cucumber.rb:24:in `name_from_scenario'
      /home/tyler/.rvm/gems/ree-1.8.7-2011.12@flexd/gems/sauce-1.1.24/lib/sauce/capybara/cucumber.rb:55:in `around_hook'
      /home/tyler/.rvm/gems/ree-1.8.7-2011.12@flexd/gems/sauce-1.1.24/lib/sauce/config.rb:8:in `config'
      /home/tyler/.rvm/gems/ree-1.8.7-2011.12@flexd/gems/sauce-1.1.24/lib/sauce/capybara/cucumber.rb:54:in `around_hook'
      /home/tyler/.rvm/gems/ree-1.8.7-2011.12@flexd/gems/sauce-1.1.24/lib/sauce/capybara/cucumber.rb:109:in `Around'

Missed a spot.

Cucumber retry was a bad idea.

Turns out, this was a generally bad thing and can cause all sorts of really funky issues when used for actual Scenarios instead of stupid mocked out ones in RSpec.

Instead of retrying the entire Scenario, we'll just be opinionated and make sure that Capybara will catch and retry individual actions if a Selenium::WebDriver::Errors::UnknownError occurs

Two Around hooks will receive different Sauce::Config objects

If the user requires sauce/capybara/cucumber and defines their own Around('@selenium') hook, they will have issues when calling Sauce.config { } as it will yield a different object for the gem's Around, versus the user's Around.

Confusing AMIRITE.

This may be a bug in how Sauce.config yields a new Sauce::Config object

config with heroku

We recently have been using a gem on a project and ran into a problem with it loading heroku config (#load_options_from_heroku). The problem occurs when we have the gem heroku install in our Gemfile, but have no configured heroku yet, as we are only developing locally -- not deploying.

The function (#load_options_from_heroku) does not take into account that someone has not typed in their credentials yet into heroku, so it waits for email and password credentials. Since its piping all of STDOUT to dev/null this was obvious to us when we were running our specs.

Can this be fixed, or made optional?

Support for the REST API is needed

I might tackle this in a pull request.

Some form of an API to access the Sauce Labs REST API is needed, in order to pass custom data or even :passed to the job

Automatically start/stop Sauce-Connect.jar

I wrote this wrapper into my helper and test suite files and thought it might be of use to some other folks:

# helper.rb
# Add this in addition to your normal helper code
require 'net/http'
require 'zipruby'

ready_file = 'sauce_ready'
sauce_file = 'Sauce-Connect.jar'

unless File.exists?(sauce_file)
  puts "Fetching Sauce-Connect.jar"
  url = "http://saucelabs.com/downloads/Sauce-Connect-latest.zip"

  Zip::Archive.open_buffer(Net::HTTP.get(URI.parse(url))) do |zf|
    zf.fopen(sauce_file) do |f|
      open(sauce_file,'wb') do |file|
        file.write(f.read)
      end
    end
  end
end

# Get the Sauce configuration information
cfg = Sauce::Config.new()
# Create a command to spawn the jar file
cmd = "java -jar #{sauce_file} -f #{ready_file} #{cfg.opts[:username]} #{cfg.opts[:access_key]}"

# Run the command
`#{cmd} > /dev/null 2>&1 &`
@sauce_connect_pid = $?.pid
puts "Connect PID: #{@sauce_connect_pid}"

# Wait for Sauce to be ready
until File.exists?(ready_file)
  puts "Waiting for Sauce Connect"
  sleep 5
end
#testsuite.rb
require "test/unit"
require "test/unit/testsuite"
require "test/unit/ui/console/testrunner"
require 'helper'
require 'tc_home'
require 'tc_ajax'

# Need to load the tests manualls so we can
#   override at_exit
class TS_web
  def self.suite
    suite = Test::Unit::TestSuite.new('Sauce Tests')
    suite << AJAX.suite
    suite << Home.suite
    return suite
  end
end

# Need to do this for now in order to kill the 
#   process when we're done
Test::Unit::UI::Console::TestRunner.run(TS_web);

# HACK: pid is of the `cmd`, which spawns java
at_exit{ Process.kill('TERM',@sauce_connect_pid+1);}

Sauce::Config cannot accept hyphenated options except in constructor

If you try to set configuration values that require a hyphen (such as "selenium-version") after the fact through the method_missing magic, e.g.:

  Sauce::Config do |config|
    config.selenium_version = '2.7.0'
  end

This will send "selenium_version" along instead of the intended capability.

Either we can clean up some of this gnarliness or we can just take the @opts and replace _ with - inside of #to_desired_capabilities

All solutions are the gross.

SSL errors with Sauce::TestCase

I am getting this error on my Rails server when trying to run the tests on my local machine following the 'Test::Unit integration without Rails' example. My test app is only accessible via HTTPS (since in PROD we have Apache handle redirection). I am not sure if it is related to my configuration (included at the bottom).

[2011-10-11 11:48:46] ERROR OpenSSL::SSL::SSLError: SSL_accept SYSCALL returned=5 errno=0 state=SSLv2/v3 read client hello A   
        /usr/lib/ruby/1.8/openssl/ssl-internal.rb:166:in `accept'

My test script gets these errors:

  1) Failure:
test_sauce(ExampleTest)
    [test.rb:24:in `test_sauce'
     /usr/lib/ruby/gems/1.8/gems/sauce-1.0.2/lib/sauce/integrations.rb:202:in `run'
     /usr/lib/ruby/gems/1.8/gems/sauce-1.0.2/lib/sauce/integrations.rb:173:in `each'
     /usr/lib/ruby/gems/1.8/gems/sauce-1.0.2/lib/sauce/integrations.rb:173:in `run']:
<false> is not true.

Configuration:

hostname = Socket.gethostbyname(Socket.gethostname).first    #returns FQDN which works locally

# This should go in your test_helper.rb file if you have one                                                           
Sauce.config do |config|                                                                                               
  config.browser_url = "https://#{hostname}"                                                                           

  # uncomment this if your server is not publicly accessible                                                           
  config.application_host = hostname                                                                                   
  config.application_port = "443"                                                                                      
end

"You may start your tests." regex is really really stupid

The Java connector will output two strings:

2012-03-01 14:14:28,510 - Please wait for "You may start your tests" to start your tests.
2012-03-01 14:14:59,177 - Connected! You may start your tests.

The current regular expression /You may start your tests\./ is only matching the second case because it's using a period at the end.

lolwut

Error with Capybara

When trying to run a test with Capybara in Ruby I cam getting this error:

RuntimeError: Capybara::Driver::Selenium has been renamed to Capybara::Selenium::Driver

Why would this happen?

Look at incorporating some automatic rake tasks

I should provide a pull request for this

Basically port some of Lookout's rake tasks to provide:

rake test:sauce:all                         # Run test:browser against all browsers with Sauce
rake test:sauce:chrome                      # Run test:browser against Chrome with Sauce
rake test:sauce:firefox:4                   # Run test:browser against Firefox 4 with Sauce
rake test:sauce:firefox:5                   # Run test:browser against Firefox 5 with Sauce
rake test:sauce:firefox:6                   # Run test:browser against Firefox 6 with Sauce
rake test:sauce:ie:7                        # Run test:browser against IE7 with Sauce
rake test:sauce:ie:8                        # Run test:browser against IE8 with Sauce
rake test:sauce:ie:9                        # Run test:browser against IE9 with Sauce

Use Bundler

Installing development dependencies via 'rake check_dependencies' is manual and painful.

Saucelabs, Capybara and non-rack sites

It would be nice if the capybara integration was able to test external sites.
When creating a sauce tunnel in https://github.com/saucelabs/sauce_ruby/blob/master/lib/sauce/capybara.rb#L10, you hardcode "127.0.0.1" and the "rack_server.port" endpoints of the tunnel.

What I'd like to be able to do is using Capybara and sauce to test sites that are NOT running on a local rack server.
This is usually possible using the Capybara.app_host variable and should also be possible using the browser_url configuration option that can be passed to the sauce gem.

Parallel testing

Browser testing is slow. Parallel browser testing is fast. The sauce gem should make parallel testing easy.

SSL Support

I want to have a selenium instance like this configured so I can use capybara's methods to manipulate it, because the way this gem currently sets things up prevents me from running capybara against a remote ssl host:

Selenium::Client::Driver.new(¬                                                                                                                                                                                                                                                                                                                      
  :host => "saucelabs.com",¬                                                                                                                                                                                                                                                                                                                                     
  :port => 4444,¬                                                                                                                                                                                                                                                                                                                                                
  :browser =>·¬                                                                                                                                                                                                                                                                                                                                                  
    {¬                                                                                                                                                                                                                                                                                                                                                             
      "username" => "outright",¬                                                                                                                                                                                                                                                                                                                                   
      "access-key" => [REDACTED],¬                                                                                                                                                                                                                                                                                                     
      "os" => ENV["SAUCE_OS"] || "Windows 2003",¬                                                                                                                                                                                                                                                                                                                  
      "browser" => browser_name,¬                                                                                                                                                                                                                                                                                                                                  
      "browser-version" => ENV["SAUCE_BROWSER_VERSION"].nil? ? "3.6." : ENV["SAUCE_BROWSER_VERSION"],¬                                                                                                                                                                                                                                                             
      "job-name" => "testing 1"¬                                                                                                                                                                                                                                                                                                                                   
    }.to_json,¬                                                                                                                                                                                                                                                                                                                                                    
  :url => Capybara.app_host,¬                                                                                                                                                                                                                                                                                                                                  
  :timeout_in_second => 90¬                                                                                                                                                                                                                                                                                                                                    
)

Background steps in cucumber seem to now be broken

Not sure when this started happening, but every .feature that has a Background block in it fails with an error like this:

      You have a nil object when you didn't expect it!
      You might have expected an instance of ActiveRecord::Base.
      The error occurred while evaluating nil.[] (NoMethodError)

Current suspicion is that somehow the @browser object isn't getting created in the Capybara driver

CI::Reporter support

This may already work, but we do some crazy stuff wrapping tests that may break CI::Reporter output.

RSpec generate fails spectacularly if the project doesn't have RSpec

Using the rails3-demo which doesn't have any RSpec in it whatsoever

Probably an issue with the generator code, but we should probably be more intelligent about stock Rails projects, which use Test::Unit by default

tyler@kiwi 08:56:04 ~/source/github/gems/sauce_ruby/examples/rails3-demo [bug/64-test-rails2-and-rails3 *] ‹ruby-1.9.2@saucelabs-rails3-demo› 
-> % ./script/rails g sauce:install
      create  lib/tasks/sauce.rake
       exist  spec/selenium
      append  spec/spec_helper.rb
/home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/actions/inject_into_file.rb:99:in `binread': No such file or directory - /home/tyler/source/github/gems/sauce_ruby/examples/rails3-demo/spec/spec_helper.rb (Errno::ENOENT)
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/actions/inject_into_file.rb:99:in `replace!'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/actions/inject_into_file.rb:60:in `invoke!'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/actions.rb:95:in `action'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/actions/inject_into_file.rb:31:in `insert_into_file'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:175:in `append_to_file'
        from /home/tyler/source/github/gems/sauce_ruby/lib/generators/sauce/install/install_generator.rb:24:in `setup_spec'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/railties-3.2.0/lib/rails/generators.rb:170:in `invoke'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/railties-3.2.0/lib/rails/commands/generate.rb:12:in `<top (required)>'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `block in require'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:236:in `load_dependency'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@saucelabs-rails3-demo/gems/railties-3.2.0/lib/rails/commands.rb:29:in `<top (required)>'
        from ./script/rails:6:in `require'
        from ./script/rails:6:in `<main>'

make tests runnable from project root

require 'helper' relative to test file path. e.g.:

$ ruby test/test_config.rb
test/test_config.rb:1:in `require': no such file to load -- helper (LoadError)
from test/test_config.rb:1
$ cd test/
$ ruby test_config.rb
Loaded suite test_config
Started
.......
Finished in 0.003463 seconds.

7 tests, 8 assertions, 0 failures, 0 errors

ondemand.yml

When I run the configuration command, ondemand.yml is created in ~/.sauce

I want to use the gem as part of a continuous integration process. Where can I store this file within my project for the to be able to locate it?

Unable to run rspecs tests with devise -- undefined method `env' for nil:NilClass

Hi everyone, I installed the latest version of Sauce gem from github and run the tests but I got the same errors, and this is an old test that run without problems with rspec:

[DEPRECATED] This method (browser_url=) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (browsers=) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (application_host=) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (application_port=) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (browser_url=) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (browsers=) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (application_host=) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (application_port=) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (browser_url=) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (browsers=) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (application_host=) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (application_port=) is deprecated, please use the [] and []= accessors instead
*****************************************************************
DEPRECATION WARNING: you are using a deprecated constant that will
be removed from a future version of RSpec.

/Users/supinchecompilla/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-2.9.0/lib/rspec/core/hooks.rb:24:in `call'

* Rspec is deprecated.
* RSpec is the new top-level module in RSpec-2
*****************************************************************

*****************************************************************
DEPRECATION WARNING: you are using a deprecated constant that will
be removed from a future version of RSpec.

/Users/supinchecompilla/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-2.9.0/lib/rspec/core/hooks.rb:24:in `call'

* Rspec is deprecated.
* RSpec is the new top-level module in RSpec-2
*****************************************************************

[DEPRECATED] This method (application_host) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (application_host) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (application_port) is deprecated, please use the [] and []= accessors instead
[Connecting to Sauce OnDemand...]
[-u, <EDITED>, -k, <EDITED>, -d, sauce-connect.proxy, -s, 127.0.0.1, -p, 80, --ssh-port, 443, -b, --rest-url, https://saucelabs.com/rest/v1, --se-port, 4445, --squid-opts, ]
* Debug messages will be sent to sauce_connect.log
2012-03-31 23:12:25.397:INFO::jetty-7.x.y-SNAPSHOT
2012-03-31 23:12:25.461:INFO::Started [email protected]:59740
.---------------------------------------------------.
| Have questions or need help with Sauce Connect? |
| Contact us: http://support.saucelabs.com/forums |
| Terms of Service: http://saucelabs.com/tos |
-----------------------------------------------------
2012-03-31 23:12:25,477 - / Starting \
2012-03-31 23:12:25,483 - Please wait for "You may start your tests" to start your tests.
2012-03-31 23:12:25,493 - Forwarding: ['sauce-connect.proxy']:['80'] -> 127.0.0.1:['59740']
2012-03-31 23:12:25,510 - Succesfully connected to local server 127.0.0.1:59740 in 9ms
2012-03-31 23:12:26,101 - {"squid_config":[""],"use_caching_proxy":true,"fast_fail_regexps":[""],"ssh_port":443,"metadata":{"PythonVersion":"2.5.1","OwnerHost":"127.0.0.1","Release":"3.0-r18","OwnerPorts":["59740"],"Ports":["80"],"Platform":"Java-1.6.0_29-Java_HotSpot-TM-_64-Bit_Server_VM,_20.4-b02-402,_Apple_Inc.-on-Mac_OS_X-10.6.8-x86_64","Build":"26","ScriptRelease":26,"ScriptName":"sauce_connect"},"use_kgp":true,"domain_names":["sauce-connect.proxy"]}
2012-03-31 23:12:26,367 - Tunnel remote VM is provisioned (d69ccdae52644072bae299a1728a3656)
2012-03-31 23:12:26,635 - Tunnel remote VM is new ..
2012-03-31 23:12:29,903 - Tunnel remote VM is booting ..
2012-03-31 23:12:52,851 - Tunnel remote VM is running at maki8027.miso.saucelabs.com
2012-03-31 23:12:52,868 - Succesfully connected to local server 127.0.0.1:59740 in 0ms
2012-03-31 23:12:52,872 - Starting connection to tunnel host...
2012-03-31 23:12:52,875 - Connecting to tunnel host maki8027.miso.saucelabs.com as joseluis_torres
2012-03-31 23:12:53,058 - Forwarding Selenium with ephemeral port 59749
2012-03-31 23:12:53.061:INFO::jetty-7.x.y-SNAPSHOT
2012-03-31 23:12:53.063:INFO::Started [email protected]:4445
2012-03-31 23:12:53,065 - Selenium HTTP proxy listening on port 4445
2012-03-31 23:12:53,772 - Successful handshake with Sauce Connect server
2012-03-31 23:12:53,917 - Tunnel host version: 0.1.0, remote endpoint ID: 4ba9f6dbb9e04cd6bebd1164a9ba4390
2012-03-31 23:12:53,921 - Connected! You may start your tests.
Starting Rails server on port 3001...
WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being defered until env.rb is called.
To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile
=> Booting WEBrick
=> Rails 3.1.1 application starting in test on http://0.0.0.0:3001
=> Call with -d to detach
=> Ctrl-C to shutdown server
/Users/supinchecompilla/powhow/powhow-prod/config/environment.rb:14: warning: already initialized constant VERIFY_PEER
[2012-03-31 23:13:13] INFO WEBrick 1.3.1
[2012-03-31 23:13:13] INFO ruby 1.9.3 (2012-02-16) [x86_64-darwin10.8.0]
[2012-03-31 23:13:13] INFO WEBrick::HTTPServer#start: pid=97908 port=3001
Rails server running!
[DEPRECATED] This method (browser_url) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (capture_traffic?) is deprecated, please use the [] and []= accessors instead
F[DEPRECATED] This method (browser_url) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (capture_traffic?) is deprecated, please use the [] and []= accessors instead
2012-03-31 23:13:30,275 - GET http://fxfeeds.mozilla.com/en-US/firefox/headlines.xml -> 302 (451ms)
F[DEPRECATED] This method (browser_url) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (capture_traffic?) is deprecated, please use the [] and []= accessors instead
2012-03-31 23:13:44,236 - GET http://fxfeeds.mozilla.com/firefox/headlines.xml -> 302 (183ms)
2012-03-31 23:13:45,013 - GET http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml -> 301 (469ms)
F[DEPRECATED] This method (browser_url) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (capture_traffic?) is deprecated, please use the [] and []= accessors instead
F[DEPRECATED] This method (browser_url) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (capture_traffic?) is deprecated, please use the [] and []= accessors instead
2012-03-31 23:14:14,259 - GET http://feeds.bbci.co.uk/news/rss.xml?edition=int -> 200 (414ms)
F[DEPRECATED] This method (browser_url) is deprecated, please use the [] and []= accessors instead
[DEPRECATED] This method (capture_traffic?) is deprecated, please use the [] and []= accessors instead
2012-03-31 23:14:47,075 - GET https://sb-ssl.google.com/safebrowsing/newkey?client=navclient-auto-ffox&appver=3.6.21&pver=2.2 -> 200 (1220ms)
F2012-03-31 23:15:01,592 - received SIGINT
2012-03-31 23:15:01,605 - Shutting down tunnel remote VM (please wait)
2012-03-31 23:15:02,456 - Tunnel remote VM is halting ..
2012-03-31 23:15:05,773 - Finished shutting down tunnel remote VM
[2012-03-31 23:15:06] ERROR SignalException: SIGTERM
/Users/supinchecompilla/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/server.rb:98:in `select'


Failures:

1) Users::SessionsController Normal Login authentication and Facebook should allow a New User to register and log in with Facebook
Failure/Error: @request.env["devise.mapping"] = Devise.mappings[:user]
NoMethodError:
undefined method `env' for nil:NilClass
# ./spec/selenium/controllers/sessions_controller_spec.rb:7:in `block (2 levels) in <top (required)>'

2) Users::SessionsController Normal Login authentication and Facebook should allow a user from Facebook creates an account without having location and no timezone
Failure/Error: @request.env["devise.mapping"] = Devise.mappings[:user]
NoMethodError:
undefined method `env' for nil:NilClass
# ./spec/selenium/controllers/sessions_controller_spec.rb:7:in `block (2 levels) in <top (required)>'

3) Users::SessionsController Normal Login authentication and Facebook should allow an existing User to log in with Facebook
Failure/Error: @request.env["devise.mapping"] = Devise.mappings[:user]
NoMethodError:
undefined method `env' for nil:NilClass
# ./spec/selenium/controllers/sessions_controller_spec.rb:7:in `block (2 levels) in <top (required)>'

4) Users::SessionsController Normal Login authentication and Facebook should show a message with a failed user creation for duplicate email
Failure/Error: @request.env["devise.mapping"] = Devise.mappings[:user]
NoMethodError:
undefined method `env' for nil:NilClass
# ./spec/selenium/controllers/sessions_controller_spec.rb:7:in `block (2 levels) in <top (required)>'

5) Users::SessionsController Normal Login authentication and Facebook should create a new user with the register form
Failure/Error: @request.env["devise.mapping"] = Devise.mappings[:user]
NoMethodError:
undefined method `env' for nil:NilClass
# ./spec/selenium/controllers/sessions_controller_spec.rb:7:in `block (2 levels) in <top (required)>'

6) Users::SessionsController Normal Login authentication and Facebook should show a message with a failed user creation because invalid email address
Failure/Error: @request.env["devise.mapping"] = Devise.mappings[:user]
NoMethodError:
undefined method `env' for nil:NilClass
# ./spec/selenium/controllers/sessions_controller_spec.rb:7:in `block (2 levels) in <top (required)>'

Finished in 3 minutes 0.59561 seconds
6 examples, 6 failures

Failed examples:

rspec ./spec/selenium/controllers/sessions_controller_spec.rb:12 # Users::SessionsController Normal Login authentication and Facebook should allow a New User to register and log in with Facebook
rspec ./spec/selenium/controllers/sessions_controller_spec.rb:35 # Users::SessionsController Normal Login authentication and Facebook should allow a user from Facebook creates an account without having location and no timezone
rspec ./spec/selenium/controllers/sessions_controller_spec.rb:56 # Users::SessionsController Normal Login authentication and Facebook should allow an existing User to log in with Facebook
rspec ./spec/selenium/controllers/sessions_controller_spec.rb:69 # Users::SessionsController Normal Login authentication and Facebook should show a message with a failed user creation for duplicate email
rspec ./spec/selenium/controllers/sessions_controller_spec.rb:88 # Users::SessionsController Normal Login authentication and Facebook should create a new user with the register form
rspec ./spec/selenium/controllers/sessions_controller_spec.rb:103 # Users::SessionsController Normal Login authentication and Facebook should show a message with a failed user creation because invalid email address

Sauce-Connect.jar failures aren't detected cleanly

When running the TestConnect.test_error_flag the following

2012-03-01 14:14:08.835:INFO::jetty-7.x.y-SNAPSHOT
2012-03-01 14:14:08.865:INFO::Started [email protected]:50512
.---------------------------------------------------.
|  Have questions or need help with Sauce Connect?  |
|  Contact us: http://support.saucelabs.com/forums  |
|  Terms of Service: http://saucelabs.com/tos       |
-----------------------------------------------------
2012-03-01 14:14:08,878 - / Starting \
2012-03-01 14:14:08,882 - Please wait for "You may start your tests" to start your tests.
2012-03-01 14:14:08,892 - Forwarding: ['sauce-connect.proxy']:['80'] -> 127.0.0.1:['50512']
2012-03-01 14:14:08,910 - Succesfully connected to local server 127.0.0.1:50512 in 11ms
Traceback (most recent call last):
  File "__pyclasspath__/java_urllib2.py", line 41, in open
IOException: java.io.IOException: Server returned HTTP response code: 401 for URL: https://saucelabs.com/rest/v1/fail/tunnels?full=1

The Jython exception is raised and then the process errors out immediately :(

Rspec 2 support

I am getting this error

The stack trace seems to indicate tour gem do es not work for rspec 2 am i right?

/Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/sauce-1.0.2/lib/sauce/integrations.rb:122:in `block in <module:SeleniumExampleGroup>': undefined method `settings' for #<RSpec::Core::Configuration:0x007feec590ba30> (NoMethodError)
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:24:in `call'
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:24:in `call'
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:37:in `run_in'
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:70:in `block in run_all'
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:70:in `each'
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:70:in `run_all'
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:368:in `run_hook'
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:27:in `block in run'
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/reporter.rb:34:in `report'
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:25:in `run'
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
    from /Users/pair/.rvm/gems/ruby-1.9.2-p290@gronkowski/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'

Capybara.app_host = "https://something.com"

I am trying to use capybara to test a remote https url, the proxying seems to break since the ssl isnt going all the way through from server to client. It there a way to not have the sauce gem proxy but actually go to the app_host?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.