Sha256: 2236f662ad813f3ccecc429e50dc900b0fd307826dadb009aa724dacd995643c

Contents?: true

Size: 1.47 KB

Versions: 38

Compression:

Stored size: 1.47 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../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

38 entries across 38 versions & 3 rubygems

Version Path
cucumber-0.8.7 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.10.7 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.10.6 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.10.5 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.10.3 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.10.2 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.10.1 spec/cucumber/wire_support/connection_spec.rb
stefl-cucumber-0.10.1 spec/cucumber/wire_support/connection_spec.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/cucumber-0.9.4/spec/cucumber/wire_support/connection_spec.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/cucumber-0.9.4/spec/cucumber/wire_support/connection_spec.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/cucumber-0.9.4/spec/cucumber/wire_support/connection_spec.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/cucumber-0.9.4/spec/cucumber/wire_support/connection_spec.rb
cucumber-0.10.0 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.9.4 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.9.3 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.9.2 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.9.1 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.9.0 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.8.5 spec/cucumber/wire_support/connection_spec.rb
cucumber-0.8.4 spec/cucumber/wire_support/connection_spec.rb