Sha256: 4f7db00234ffad42a023027051f15b5d376010c8d74806c4f1ab3a2fd4304541

Contents?: true

Size: 1.69 KB

Versions: 19

Compression:

Stored size: 1.69 KB

Contents

require 'cucumber/wire/connection'
require 'cucumber/wire/configuration'

module Cucumber
  module Wire
    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
        allow(Timeout).to receive(:timeout).and_raise(Timeout::Error.new(''))
        expect(-> { @connection.call_remote(nil, :foo, []) }).to raise_error(Timeout::Error)
      end

      it "ignores timeout errors when configured to do so" do
        @config.custom_timeout[:foo] = :never

        allow(@socket).to receive(:gets) { @response }

        handler = double(:handle_response => :response)

        expect(@connection.call_remote(handler, :foo, [])).to eq :response
      end

      it "raises an exception on remote connection closed" do
        @config.custom_timeout[:foo] = :never

        allow(@socket).to receive(:gets)
        expect(-> {
          @connection.call_remote(nil, :foo, [])
        }).to raise_error(Wire::Exception, 'Remote Socket with localhost:3902 closed.')
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
cucumber-wire-6.2.1 spec/cucumber/wire/connection_spec.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/cucumber-wire-6.2.0/spec/cucumber/wire/connection_spec.rb
cucumber-wire-6.2.0 spec/cucumber/wire/connection_spec.rb
cucumber-wire-6.1.1 spec/cucumber/wire/connection_spec.rb
cucumber-wire-6.1.0 spec/cucumber/wire/connection_spec.rb
cucumber-wire-6.0.1 spec/cucumber/wire/connection_spec.rb
cucumber-wire-6.0.0 spec/cucumber/wire/connection_spec.rb
cucumber-wire-5.0.1 spec/cucumber/wire/connection_spec.rb
cucumber-wire-5.0.0 spec/cucumber/wire/connection_spec.rb
cucumber-wire-4.0.1 spec/cucumber/wire/connection_spec.rb
cucumber-wire-3.1.0 spec/cucumber/wire/connection_spec.rb
cucumber-wire-3.0.0 spec/cucumber/wire/connection_spec.rb
cucumber-wire-2.0.1 spec/cucumber/wire/connection_spec.rb
cucumber-wire-2.0.0 spec/cucumber/wire/connection_spec.rb
cucumber-wire-1.2.0 spec/cucumber/wire/connection_spec.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/cucumber-wire-0.0.1/spec/cucumber/wire/connection_spec.rb
cucumber-wire-1.1.0 spec/cucumber/wire/connection_spec.rb
cucumber-wire-1.0.0 spec/cucumber/wire/connection_spec.rb
cucumber-wire-0.0.1 spec/cucumber/wire/connection_spec.rb