Sha256: be69dd8e9d9ccc6d2aca7c95653d18cc2396b1b77f6cb4bdba769244c7a409c8

Contents?: true

Size: 1.97 KB

Versions: 6

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'
require 'sauce/connect'



describe 'Sauce::Connect integration testing' do
  def make_connection
    Sauce::Connect.new({})
  end

  before :each do
    Sauce.clear_config
  end

  context 'assuming valid Sauce Labs authentication' do
    # Defining a nil in the let since the before block will run after the let.
    # Running make_connection inside of a `let` block could end up with us
    # using the previous test's Sauce.config. BAD NEWS
    before :each do
      @conn = make_connection
    end

    it 'should have start with an uninitialized status' do
      @conn.status.should == 'uninitialized'
    end

    it 'should have a "running" status if the tunnel is connected' do
      @conn.connect
      @conn.wait_until_ready
      @conn.status.should == 'running'
    end

    after :each do
      @conn.disconnect if @conn
    end
  end

  context 'assuming an invalid/nonexistent username' do
    before :each do
      Sauce.config do |config|
        config[:username] = nil
        config[:access_key] = nil
      end
    end

    it 'should fail if the SAUCE_USERNAME is also empty' do
      expect {
        ENV['SAUCE_USERNAME'] = nil
        make_connection
      }.to raise_error(ArgumentError)
    end

    it 'should fail if the SAUCE_ACCESS_KEY is empty' do
      expect {
        ENV['SAUCE_USERNAME'] = 'testman'
        ENV['SAUCE_ACCESS_KEY'] = nil
        make_connection
      }.to raise_error(ArgumentError)

    end

    after :each do
      ENV['SAUCE_USERNAME'] = nil
    end
  end

  context 'assuming the "fail" username' do
    let(:conn) { Sauce::Connect.new(:host => 'saucelabs.com',
                                    :port => 80,
                                    :username => 'fail') }

    it 'should set the error status' do
      start = Time.now
      conn.connect
      while ((Time.now - start) < 60) && !conn.error
        sleep 0.5
      end

      conn.error.should_not be nil
    end

    after :each do
      conn.disconnect
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sauce-2.4.0 spec/integration/connect_integration_spec.rb
sauce-2.3.6 spec/integration/connect_integration_spec.rb
sauce-2.3.5 spec/integration/connect_integration_spec.rb
sauce-2.3.4 spec/integration/connect_integration_spec.rb
sauce-2.3.3 spec/integration/connect_integration_spec.rb
sauce-2.3.2 spec/integration/connect_integration_spec.rb