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
candlepin-api-0.4.0 bundle/ruby/gems/cucumber-1.2.1/spec/cucumber/wire_support/connection_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/cucumber-1.2.1/spec/cucumber/wire_support/connection_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/cucumber-1.2.1/spec/cucumber/wire_support/connection_spec.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/cucumber-1.2.1/spec/cucumber/wire_support/connection_spec.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/cucumber-1.2.1/spec/cucumber/wire_support/connection_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/cucumber-1.2.1/spec/cucumber/wire_support/connection_spec.rb
casecumber-1.0.2.1 spec/cucumber/wire_support/connection_spec.rb
casecumber-1.2.1.cb2 spec/cucumber/wire_support/connection_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/cucumber-1.2.1/spec/cucumber/wire_support/connection_spec.rb
cucumber-1.2.1 spec/cucumber/wire_support/connection_spec.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/spec/cucumber/wire_support/connection_spec.rb
ftl-0.2.0 vendor/bundle/gems/cucumber-1.2.0/spec/cucumber/wire_support/connection_spec.rb
cucumber-1.2.0 spec/cucumber/wire_support/connection_spec.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/spec/cucumber/wire_support/connection_spec.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/spec/cucumber/wire_support/connection_spec.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/spec/cucumber/wire_support/connection_spec.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/spec/cucumber/wire_support/connection_spec.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/spec/cucumber/wire_support/connection_spec.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/spec/cucumber/wire_support/connection_spec.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/cucumber-1.1.9/spec/cucumber/wire_support/connection_spec.rb