Sha256: 4228f4623c92cfed4dd7b53def9410af8998024ae961fc3daefe2ef1760d01c0

Contents?: true

Size: 1.42 KB

Versions: 39

Compression:

Stored size: 1.42 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] || :custom_timeout
        end
      end
      
      before(:each) do
        @config = TestConfiguration.new
        @connection = TestConnection.new(@config)
        @connection.socket = @socket = mock('socket')
        Timeout.stub(:timeout).with(:custom_timeout).and_raise(Timeout::Error.new(''))
        @response = %q{["response"]}
        Timeout.stub(:timeout).with(:default_timeout).and_return(@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.should_receive(:gets).and_return(@response)
        handler = mock(:handle_response => :response)
        @connection.call_remote(handler, :foo, []).should == :response
      end
    end
  end
end

Version data entries

39 entries across 37 versions & 9 rubygems

Version Path
cucumber-1.1.9 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.1.8 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.1.7 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.1.6 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.1.5 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.1.4 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.1.3 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.1.2 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.1.1 spec/cucumber/wire_support/connection_spec.rb
js-log-cucumber-1.0.2 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.1.0 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.0.6 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.0.5 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.0.4 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.0.3 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.0.2 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.0.1 spec/cucumber/wire_support/connection_spec.rb
cucumber-1.0.0 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.8.6 spec/cucumber/wire_support/connection_spec.rb