Sha256: 944554f04b85b38c7419883592bee69917330bba1746e47059baa1ef73194b5f

Contents?: true

Size: 1.66 KB

Versions: 21

Compression:

Stored size: 1.66 KB

Contents

require 'spec_helper'
require 'cucumber/wire_support/wire_language'

module Cucumber
  module WireSupport
    describe Connection do
      class TestConnection < Connection
        attr_accessor :socket
      end

      class TestConfiguration
        attr_reader :custom_timeout

        def initialize
          @custom_timeout = {}
        end

        def timeout(message = nil)
          return :default_timeout if message.nil?
          @custom_timeout[message] || Configuration::DEFAULT_TIMEOUTS.fetch(message)
        end

        def host
          'localhost'
        end

        def port
          '3902'
        end
      end

      before(:each) do
        @config = TestConfiguration.new
        @connection = TestConnection.new(@config)
        @connection.socket = @socket = double('socket').as_null_object
        @response = %q{["response"]}
      end

      it "re-raises a timeout error" do
        Timeout.stub(:timeout).and_raise(Timeout::Error.new(''))
        lambda { @connection.call_remote(nil, :foo, []) }.should raise_error(Timeout::Error)
      end

      it "ignores timeout errors when configured to do so" do
        @config.custom_timeout[:foo] = :never
        @socket.stub(:gets => @response)
        handler = double(:handle_response => :response)
        @connection.call_remote(handler, :foo, []).should == :response
      end

      it "raises an exception on remote connection closed" do
        @config.custom_timeout[:foo] = :never
        @socket.stub(:gets => nil)
        lambda { 
          @connection.call_remote(nil, :foo, []) 
        }.should raise_error(WireException, 'Remote Socket with localhost:3902 closed.')
      end
    end
  end
end

Version data entries

21 entries across 19 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/cucumber-1.3.18/spec/cucumber/wire_support/connection_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/cucumber-1.3.18/spec/cucumber/wire_support/connection_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/cucumber-1.3.16/spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.20 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.19 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.18 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.17 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.16 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.15 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.14 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.13 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.12 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.11 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.10 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.9 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.8 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.7 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.6 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.5 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.3.4 spec/cucumber/wire_support/connection_spec.rb